<!DOCTYPE html>
<html lang="en-US" dir="ltr">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <title>应用安装 | VitePress</title>
    <meta name="description" content="A VitePress site">
    <link rel="preload stylesheet" href="/notebook/assets/style.3dbfd0c2.css" as="style">
    
    <script type="module" src="/notebook/assets/app.8aaa4cbe.js"></script>
    <link rel="preload" href="/notebook/assets/inter-roman-latin.2ed14f66.woff2" as="font" type="font/woff2" crossorigin="">
    <link rel="modulepreload" href="/notebook/assets/chunks/framework.1336c4e5.js">
    <link rel="modulepreload" href="/notebook/assets/chunks/theme.20cddc0c.js">
    <link rel="modulepreload" href="/notebook/assets/可视化 _ 监控_监控进阶.md.0cdbc292.lean.js">
    <script id="check-dark-light">(()=>{const e=localStorage.getItem("vitepress-theme-appearance")||"",a=window.matchMedia("(prefers-color-scheme: dark)").matches;(!e||e==="auto"?a:e==="dark")&&document.documentElement.classList.add("dark")})();</script>
  </head>
  <body>
    <div id="app"><div class="Layout" data-v-255ec12d><!--[--><!--]--><!--[--><span tabindex="-1" data-v-ae3e3f51></span><a href="#VPContent" class="VPSkipLink visually-hidden" data-v-ae3e3f51> Skip to content </a><!--]--><!----><header class="VPNav" data-v-255ec12d data-v-7e5bc4a5><div class="VPNavBar has-sidebar" data-v-7e5bc4a5 data-v-0937f67c><div class="container" data-v-0937f67c><div class="title" data-v-0937f67c><div class="VPNavBarTitle has-sidebar" data-v-0937f67c data-v-86d1bed8><a class="title" href="/notebook/" data-v-86d1bed8><!--[--><!--]--><!--[--><img class="VPImage logo" src="/notebook/Vue.png" alt data-v-8426fc1a><!--]--><!--[-->任硕的文档<!--]--><!--[--><!--]--></a></div></div><div class="content" data-v-0937f67c><div class="curtain" data-v-0937f67c></div><div class="content-body" data-v-0937f67c><!--[--><!--]--><div class="VPNavBarSearch search" style="--vp-meta-key:&#39;Meta&#39;;" data-v-0937f67c><!--[--><!----><div id="docsearch"><button type="button" class="DocSearch DocSearch-Button" aria-label="Search"><span class="DocSearch-Button-Container"><svg class="DocSearch-Search-Icon" width="20" height="20" viewBox="0 0 20 20" aria-label="search icon"><path d="M14.386 14.386l4.0877 4.0877-4.0877-4.0877c-2.9418 2.9419-7.7115 2.9419-10.6533 0-2.9419-2.9418-2.9419-7.7115 0-10.6533 2.9418-2.9419 7.7115-2.9419 10.6533 0 2.9419 2.9418 2.9419 7.7115 0 10.6533z" stroke="currentColor" fill="none" fill-rule="evenodd" stroke-linecap="round" stroke-linejoin="round"></path></svg><span class="DocSearch-Button-Placeholder">Search</span></span><span class="DocSearch-Button-Keys"><kbd class="DocSearch-Button-Key"></kbd><kbd class="DocSearch-Button-Key">K</kbd></span></button></div><!--]--></div><nav aria-labelledby="main-nav-aria-label" class="VPNavBarMenu menu" data-v-0937f67c data-v-7f418b0f><span id="main-nav-aria-label" class="visually-hidden" data-v-7f418b0f>Main Navigation</span><!--[--><!--[--><div class="VPFlyout VPNavBarMenuGroup" data-v-7f418b0f data-v-a7b5672a><button type="button" class="button" aria-haspopup="true" aria-expanded="false" data-v-a7b5672a><span class="text" data-v-a7b5672a><!----><span data-v-a7b5672a>Java学前端</span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" viewbox="0 0 24 24" class="text-icon" data-v-a7b5672a><path d="M12,16c-0.3,0-0.5-0.1-0.7-0.3l-6-6c-0.4-0.4-0.4-1,0-1.4s1-0.4,1.4,0l5.3,5.3l5.3-5.3c0.4-0.4,1-0.4,1.4,0s0.4,1,0,1.4l-6,6C12.5,15.9,12.3,16,12,16z"></path></svg></span></button><div class="menu" data-v-a7b5672a><div class="VPMenu" data-v-a7b5672a data-v-e7ea1737><div class="items" data-v-e7ea1737><!--[--><!--[--><div class="VPMenuGroup" data-v-e7ea1737 data-v-69e747b5><!----><!--[--><!--[--><div class="VPMenuLink" data-v-69e747b5 data-v-2f2cfafc><a class="VPLink link" href="/notebook/Java%E5%AD%A6%E5%89%8D%E7%AB%AF/HTML+JS.html" data-v-2f2cfafc><!--[-->HTML+JS<!--]--></a></div><!--]--><!--[--><div class="VPMenuLink" data-v-69e747b5 data-v-2f2cfafc><a class="VPLink link" href="/notebook/Java%E5%AD%A6%E5%89%8D%E7%AB%AF/CSS.html" data-v-2f2cfafc><!--[-->CSS<!--]--></a></div><!--]--><!--[--><div class="VPMenuLink" data-v-69e747b5 data-v-2f2cfafc><a class="VPLink link" href="/notebook/Java%E5%AD%A6%E5%89%8D%E7%AB%AF/Vue2+%E7%BB%84%E4%BB%B6.html" data-v-2f2cfafc><!--[-->Vue2+组件<!--]--></a></div><!--]--><!--[--><div class="VPMenuLink" data-v-69e747b5 data-v-2f2cfafc><a class="VPLink link" href="/notebook/Java%E5%AD%A6%E5%89%8D%E7%AB%AF/Vue3+%E7%BB%84%E4%BB%B6.html" data-v-2f2cfafc><!--[-->Vue3+组件<!--]--></a></div><!--]--><!--[--><div class="VPMenuLink" data-v-69e747b5 data-v-2f2cfafc><a class="VPLink link" href="/notebook/Java%E5%AD%A6%E5%89%8D%E7%AB%AF/React.html" data-v-2f2cfafc><!--[-->React<!--]--></a></div><!--]--><!--]--></div><!--]--><!--]--></div><!--[--><!--]--></div></div></div><!--]--><!--[--><div class="VPFlyout VPNavBarMenuGroup" data-v-7f418b0f data-v-a7b5672a><button type="button" class="button" aria-haspopup="true" aria-expanded="false" data-v-a7b5672a><span class="text" data-v-a7b5672a><!----><span data-v-a7b5672a>软件测试</span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" viewbox="0 0 24 24" class="text-icon" data-v-a7b5672a><path d="M12,16c-0.3,0-0.5-0.1-0.7-0.3l-6-6c-0.4-0.4-0.4-1,0-1.4s1-0.4,1.4,0l5.3,5.3l5.3-5.3c0.4-0.4,1-0.4,1.4,0s0.4,1,0,1.4l-6,6C12.5,15.9,12.3,16,12,16z"></path></svg></span></button><div class="menu" data-v-a7b5672a><div class="VPMenu" data-v-a7b5672a data-v-e7ea1737><div class="items" data-v-e7ea1737><!--[--><!--[--><div class="VPMenuGroup" data-v-e7ea1737 data-v-69e747b5><!----><!--[--><!--[--><div class="VPMenuLink" data-v-69e747b5 data-v-2f2cfafc><a class="VPLink link" href="/notebook/%E8%BD%AF%E4%BB%B6%E6%B5%8B%E8%AF%95/%E6%B5%8B%E8%AF%95%E5%9F%BA%E7%A1%80.html" data-v-2f2cfafc><!--[-->测试基础<!--]--></a></div><!--]--><!--[--><div class="VPMenuLink" data-v-69e747b5 data-v-2f2cfafc><a class="VPLink link" href="/notebook/%E8%BD%AF%E4%BB%B6%E6%B5%8B%E8%AF%95/%E5%8E%8B%E5%8A%9B%E6%B5%8B%E8%AF%95.html" data-v-2f2cfafc><!--[-->压力测试<!--]--></a></div><!--]--><!--]--></div><!--]--><!--]--></div><!--[--><!--]--></div></div></div><!--]--><!--[--><div class="VPFlyout VPNavBarMenuGroup" data-v-7f418b0f data-v-a7b5672a><button type="button" class="button" aria-haspopup="true" aria-expanded="false" data-v-a7b5672a><span class="text" data-v-a7b5672a><!----><span data-v-a7b5672a>多线程</span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" viewbox="0 0 24 24" class="text-icon" data-v-a7b5672a><path d="M12,16c-0.3,0-0.5-0.1-0.7-0.3l-6-6c-0.4-0.4-0.4-1,0-1.4s1-0.4,1.4,0l5.3,5.3l5.3-5.3c0.4-0.4,1-0.4,1.4,0s0.4,1,0,1.4l-6,6C12.5,15.9,12.3,16,12,16z"></path></svg></span></button><div class="menu" data-v-a7b5672a><div class="VPMenu" data-v-a7b5672a data-v-e7ea1737><div class="items" data-v-e7ea1737><!--[--><!--[--><div class="VPMenuGroup" data-v-e7ea1737 data-v-69e747b5><!----><!--[--><!--[--><div class="VPMenuLink" data-v-69e747b5 data-v-2f2cfafc><a class="VPLink link" href="/notebook/%E5%B9%B6%E5%8F%91%20&amp;%20%E5%A4%9A%E7%BA%BF%E7%A8%8B/%E5%9F%BA%E7%A1%80%E7%AF%87.html" data-v-2f2cfafc><!--[-->基础篇<!--]--></a></div><!--]--><!--[--><div class="VPMenuLink" data-v-69e747b5 data-v-2f2cfafc><a class="VPLink link" href="/notebook/%E5%B9%B6%E5%8F%91%20&amp;%20%E5%A4%9A%E7%BA%BF%E7%A8%8B/%E5%B9%B6%E5%8F%91%E5%AE%8C%E5%96%84.html" data-v-2f2cfafc><!--[-->进阶篇<!--]--></a></div><!--]--><!--]--></div><!--]--><!--]--></div><!--[--><!--]--></div></div></div><!--]--><!--[--><div class="VPFlyout VPNavBarMenuGroup" data-v-7f418b0f data-v-a7b5672a><button type="button" class="button" aria-haspopup="true" aria-expanded="false" data-v-a7b5672a><span class="text" data-v-a7b5672a><!----><span data-v-a7b5672a>开发工具</span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" viewbox="0 0 24 24" class="text-icon" data-v-a7b5672a><path d="M12,16c-0.3,0-0.5-0.1-0.7-0.3l-6-6c-0.4-0.4-0.4-1,0-1.4s1-0.4,1.4,0l5.3,5.3l5.3-5.3c0.4-0.4,1-0.4,1.4,0s0.4,1,0,1.4l-6,6C12.5,15.9,12.3,16,12,16z"></path></svg></span></button><div class="menu" data-v-a7b5672a><div class="VPMenu" data-v-a7b5672a data-v-e7ea1737><div class="items" data-v-e7ea1737><!--[--><!--[--><div class="VPMenuGroup" data-v-e7ea1737 data-v-69e747b5><!----><!--[--><!--[--><div class="VPMenuLink" data-v-69e747b5 data-v-2f2cfafc><a class="VPLink link" href="/notebook/IDEA/Chrome.html" data-v-2f2cfafc><!--[-->Chrome<!--]--></a></div><!--]--><!--[--><div class="VPMenuLink" data-v-69e747b5 data-v-2f2cfafc><a class="VPLink link" href="/notebook/IDEA/IDEA%E5%9F%BA%E7%A1%80.html" data-v-2f2cfafc><!--[-->IDEA基础<!--]--></a></div><!--]--><!--[--><div class="VPMenuLink" data-v-69e747b5 data-v-2f2cfafc><a class="VPLink link" href="/notebook/IDEA/IDEA%E6%8F%92%E4%BB%B6.html" data-v-2f2cfafc><!--[-->IDEA插件<!--]--></a></div><!--]--><!--[--><div class="VPMenuLink" data-v-69e747b5 data-v-2f2cfafc><a class="VPLink link" href="/notebook/IDEA/VS%20Code.html" data-v-2f2cfafc><!--[-->VS Code<!--]--></a></div><!--]--><!--]--></div><!--]--><!--]--></div><!--[--><!--]--></div></div></div><!--]--><!--[--><div class="VPFlyout VPNavBarMenuGroup" data-v-7f418b0f data-v-a7b5672a><button type="button" class="button" aria-haspopup="true" aria-expanded="false" data-v-a7b5672a><span class="text" data-v-a7b5672a><!----><span data-v-a7b5672a>消息中间件</span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" viewbox="0 0 24 24" class="text-icon" data-v-a7b5672a><path d="M12,16c-0.3,0-0.5-0.1-0.7-0.3l-6-6c-0.4-0.4-0.4-1,0-1.4s1-0.4,1.4,0l5.3,5.3l5.3-5.3c0.4-0.4,1-0.4,1.4,0s0.4,1,0,1.4l-6,6C12.5,15.9,12.3,16,12,16z"></path></svg></span></button><div class="menu" data-v-a7b5672a><div class="VPMenu" data-v-a7b5672a data-v-e7ea1737><div class="items" data-v-e7ea1737><!--[--><!--[--><div class="VPMenuGroup" data-v-e7ea1737 data-v-69e747b5><!----><!--[--><!--[--><div class="VPMenuLink" data-v-69e747b5 data-v-2f2cfafc><a class="VPLink link" href="/notebook/%E6%B6%88%E6%81%AF%E4%B8%AD%E9%97%B4%E4%BB%B6/RabbitMQ.html" data-v-2f2cfafc><!--[-->RabbitMQ<!--]--></a></div><!--]--><!--[--><div class="VPMenuLink" data-v-69e747b5 data-v-2f2cfafc><a class="VPLink link" href="/notebook/%E6%B6%88%E6%81%AF%E4%B8%AD%E9%97%B4%E4%BB%B6/RocketMQ.html" data-v-2f2cfafc><!--[-->RocketMQ<!--]--></a></div><!--]--><!--[--><div class="VPMenuLink" data-v-69e747b5 data-v-2f2cfafc><a class="VPLink link" href="/notebook/%E6%B6%88%E6%81%AF%E4%B8%AD%E9%97%B4%E4%BB%B6/Kafka.html" data-v-2f2cfafc><!--[-->Kafka<!--]--></a></div><!--]--><!--[--><div class="VPMenuLink" data-v-69e747b5 data-v-2f2cfafc><a class="VPLink link" href="/notebook/%E6%B6%88%E6%81%AF%E4%B8%AD%E9%97%B4%E4%BB%B6/Canal.html" data-v-2f2cfafc><!--[-->Canal<!--]--></a></div><!--]--><!--]--></div><!--]--><!--]--></div><!--[--><!--]--></div></div></div><!--]--><!--]--></nav><!----><div class="VPNavBarAppearance appearance" data-v-0937f67c data-v-f6a63727><button class="VPSwitch VPSwitchAppearance" type="button" role="switch" title="toggle dark mode" aria-checked="false" data-v-f6a63727 data-v-82b282f1 data-v-f3c41672><span class="check" data-v-f3c41672><span class="icon" data-v-f3c41672><!--[--><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" viewbox="0 0 24 24" class="sun" data-v-82b282f1><path d="M12,18c-3.3,0-6-2.7-6-6s2.7-6,6-6s6,2.7,6,6S15.3,18,12,18zM12,8c-2.2,0-4,1.8-4,4c0,2.2,1.8,4,4,4c2.2,0,4-1.8,4-4C16,9.8,14.2,8,12,8z"></path><path d="M12,4c-0.6,0-1-0.4-1-1V1c0-0.6,0.4-1,1-1s1,0.4,1,1v2C13,3.6,12.6,4,12,4z"></path><path d="M12,24c-0.6,0-1-0.4-1-1v-2c0-0.6,0.4-1,1-1s1,0.4,1,1v2C13,23.6,12.6,24,12,24z"></path><path d="M5.6,6.6c-0.3,0-0.5-0.1-0.7-0.3L3.5,4.9c-0.4-0.4-0.4-1,0-1.4s1-0.4,1.4,0l1.4,1.4c0.4,0.4,0.4,1,0,1.4C6.2,6.5,5.9,6.6,5.6,6.6z"></path><path d="M19.8,20.8c-0.3,0-0.5-0.1-0.7-0.3l-1.4-1.4c-0.4-0.4-0.4-1,0-1.4s1-0.4,1.4,0l1.4,1.4c0.4,0.4,0.4,1,0,1.4C20.3,20.7,20,20.8,19.8,20.8z"></path><path d="M3,13H1c-0.6,0-1-0.4-1-1s0.4-1,1-1h2c0.6,0,1,0.4,1,1S3.6,13,3,13z"></path><path d="M23,13h-2c-0.6,0-1-0.4-1-1s0.4-1,1-1h2c0.6,0,1,0.4,1,1S23.6,13,23,13z"></path><path d="M4.2,20.8c-0.3,0-0.5-0.1-0.7-0.3c-0.4-0.4-0.4-1,0-1.4l1.4-1.4c0.4-0.4,1-0.4,1.4,0s0.4,1,0,1.4l-1.4,1.4C4.7,20.7,4.5,20.8,4.2,20.8z"></path><path d="M18.4,6.6c-0.3,0-0.5-0.1-0.7-0.3c-0.4-0.4-0.4-1,0-1.4l1.4-1.4c0.4-0.4,1-0.4,1.4,0s0.4,1,0,1.4l-1.4,1.4C18.9,6.5,18.6,6.6,18.4,6.6z"></path></svg><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" viewbox="0 0 24 24" class="moon" data-v-82b282f1><path d="M12.1,22c-0.3,0-0.6,0-0.9,0c-5.5-0.5-9.5-5.4-9-10.9c0.4-4.8,4.2-8.6,9-9c0.4,0,0.8,0.2,1,0.5c0.2,0.3,0.2,0.8-0.1,1.1c-2,2.7-1.4,6.4,1.3,8.4c2.1,1.6,5,1.6,7.1,0c0.3-0.2,0.7-0.3,1.1-0.1c0.3,0.2,0.5,0.6,0.5,1c-0.2,2.7-1.5,5.1-3.6,6.8C16.6,21.2,14.4,22,12.1,22zM9.3,4.4c-2.9,1-5,3.6-5.2,6.8c-0.4,4.4,2.8,8.3,7.2,8.7c2.1,0.2,4.2-0.4,5.8-1.8c1.1-0.9,1.9-2.1,2.4-3.4c-2.5,0.9-5.3,0.5-7.5-1.1C9.2,11.4,8.1,7.7,9.3,4.4z"></path></svg><!--]--></span></span></button></div><div class="VPSocialLinks VPNavBarSocialLinks social-links" data-v-0937f67c data-v-0394ad82 data-v-7bc22406><!--[--><a class="VPSocialLink no-icon" href="https://github.com/renshuo123/renshuo123.github.io" aria-label="github" target="_blank" rel="noopener" data-v-7bc22406 data-v-f80f8133><svg role="img" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><title>GitHub</title><path d="M12 .297c-6.63 0-12 5.373-12 12 0 5.303 3.438 9.8 8.205 11.385.6.113.82-.258.82-.577 0-.285-.01-1.04-.015-2.04-3.338.724-4.042-1.61-4.042-1.61C4.422 18.07 3.633 17.7 3.633 17.7c-1.087-.744.084-.729.084-.729 1.205.084 1.838 1.236 1.838 1.236 1.07 1.835 2.809 1.305 3.495.998.108-.776.417-1.305.76-1.605-2.665-.3-5.466-1.332-5.466-5.93 0-1.31.465-2.38 1.235-3.22-.135-.303-.54-1.523.105-3.176 0 0 1.005-.322 3.3 1.23.96-.267 1.98-.399 3-.405 1.02.006 2.04.138 3 .405 2.28-1.552 3.285-1.23 3.285-1.23.645 1.653.24 2.873.12 3.176.765.84 1.23 1.91 1.23 3.22 0 4.61-2.805 5.625-5.475 5.92.42.36.81 1.096.81 2.22 0 1.606-.015 2.896-.015 3.286 0 .315.21.69.825.57C20.565 22.092 24 17.592 24 12.297c0-6.627-5.373-12-12-12"/></svg></a><a class="VPSocialLink no-icon" href="#" aria-label="twitter" target="_blank" rel="noopener" data-v-7bc22406 data-v-f80f8133><svg role="img" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><title>Twitter</title><path d="M23.953 4.57a10 10 0 01-2.825.775 4.958 4.958 0 002.163-2.723c-.951.555-2.005.959-3.127 1.184a4.92 4.92 0 00-8.384 4.482C7.69 8.095 4.067 6.13 1.64 3.162a4.822 4.822 0 00-.666 2.475c0 1.71.87 3.213 2.188 4.096a4.904 4.904 0 01-2.228-.616v.06a4.923 4.923 0 003.946 4.827 4.996 4.996 0 01-2.212.085 4.936 4.936 0 004.604 3.417 9.867 9.867 0 01-6.102 2.105c-.39 0-.779-.023-1.17-.067a13.995 13.995 0 007.557 2.209c9.053 0 13.998-7.496 13.998-13.985 0-.21 0-.42-.015-.63A9.935 9.935 0 0024 4.59z"/></svg></a><a class="VPSocialLink no-icon" href="https://github.com/" aria-label target="_blank" rel="noopener" data-v-7bc22406 data-v-f80f8133><svg t="1676028692954" class="icon" ...</path></svg></a><!--]--></div><div class="VPFlyout VPNavBarExtra extra" data-v-0937f67c data-v-40855f84 data-v-a7b5672a><button type="button" class="button" aria-haspopup="true" aria-expanded="false" aria-label="extra navigation" data-v-a7b5672a><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" viewbox="0 0 24 24" class="icon" data-v-a7b5672a><circle cx="12" cy="12" r="2"></circle><circle cx="19" cy="12" r="2"></circle><circle cx="5" cy="12" r="2"></circle></svg></button><div class="menu" data-v-a7b5672a><div class="VPMenu" data-v-a7b5672a data-v-e7ea1737><!----><!--[--><!--[--><!----><div class="group" data-v-40855f84><div class="item appearance" data-v-40855f84><p class="label" data-v-40855f84>Appearance</p><div class="appearance-action" data-v-40855f84><button class="VPSwitch VPSwitchAppearance" type="button" role="switch" title="toggle dark mode" aria-checked="false" data-v-40855f84 data-v-82b282f1 data-v-f3c41672><span class="check" data-v-f3c41672><span class="icon" data-v-f3c41672><!--[--><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" viewbox="0 0 24 24" class="sun" data-v-82b282f1><path d="M12,18c-3.3,0-6-2.7-6-6s2.7-6,6-6s6,2.7,6,6S15.3,18,12,18zM12,8c-2.2,0-4,1.8-4,4c0,2.2,1.8,4,4,4c2.2,0,4-1.8,4-4C16,9.8,14.2,8,12,8z"></path><path d="M12,4c-0.6,0-1-0.4-1-1V1c0-0.6,0.4-1,1-1s1,0.4,1,1v2C13,3.6,12.6,4,12,4z"></path><path d="M12,24c-0.6,0-1-0.4-1-1v-2c0-0.6,0.4-1,1-1s1,0.4,1,1v2C13,23.6,12.6,24,12,24z"></path><path d="M5.6,6.6c-0.3,0-0.5-0.1-0.7-0.3L3.5,4.9c-0.4-0.4-0.4-1,0-1.4s1-0.4,1.4,0l1.4,1.4c0.4,0.4,0.4,1,0,1.4C6.2,6.5,5.9,6.6,5.6,6.6z"></path><path d="M19.8,20.8c-0.3,0-0.5-0.1-0.7-0.3l-1.4-1.4c-0.4-0.4-0.4-1,0-1.4s1-0.4,1.4,0l1.4,1.4c0.4,0.4,0.4,1,0,1.4C20.3,20.7,20,20.8,19.8,20.8z"></path><path d="M3,13H1c-0.6,0-1-0.4-1-1s0.4-1,1-1h2c0.6,0,1,0.4,1,1S3.6,13,3,13z"></path><path d="M23,13h-2c-0.6,0-1-0.4-1-1s0.4-1,1-1h2c0.6,0,1,0.4,1,1S23.6,13,23,13z"></path><path d="M4.2,20.8c-0.3,0-0.5-0.1-0.7-0.3c-0.4-0.4-0.4-1,0-1.4l1.4-1.4c0.4-0.4,1-0.4,1.4,0s0.4,1,0,1.4l-1.4,1.4C4.7,20.7,4.5,20.8,4.2,20.8z"></path><path d="M18.4,6.6c-0.3,0-0.5-0.1-0.7-0.3c-0.4-0.4-0.4-1,0-1.4l1.4-1.4c0.4-0.4,1-0.4,1.4,0s0.4,1,0,1.4l-1.4,1.4C18.9,6.5,18.6,6.6,18.4,6.6z"></path></svg><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" viewbox="0 0 24 24" class="moon" data-v-82b282f1><path d="M12.1,22c-0.3,0-0.6,0-0.9,0c-5.5-0.5-9.5-5.4-9-10.9c0.4-4.8,4.2-8.6,9-9c0.4,0,0.8,0.2,1,0.5c0.2,0.3,0.2,0.8-0.1,1.1c-2,2.7-1.4,6.4,1.3,8.4c2.1,1.6,5,1.6,7.1,0c0.3-0.2,0.7-0.3,1.1-0.1c0.3,0.2,0.5,0.6,0.5,1c-0.2,2.7-1.5,5.1-3.6,6.8C16.6,21.2,14.4,22,12.1,22zM9.3,4.4c-2.9,1-5,3.6-5.2,6.8c-0.4,4.4,2.8,8.3,7.2,8.7c2.1,0.2,4.2-0.4,5.8-1.8c1.1-0.9,1.9-2.1,2.4-3.4c-2.5,0.9-5.3,0.5-7.5-1.1C9.2,11.4,8.1,7.7,9.3,4.4z"></path></svg><!--]--></span></span></button></div></div></div><div class="group" data-v-40855f84><div class="item social-links" data-v-40855f84><div class="VPSocialLinks social-links-list" data-v-40855f84 data-v-7bc22406><!--[--><a class="VPSocialLink no-icon" href="https://github.com/renshuo123/renshuo123.github.io" aria-label="github" target="_blank" rel="noopener" data-v-7bc22406 data-v-f80f8133><svg role="img" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><title>GitHub</title><path d="M12 .297c-6.63 0-12 5.373-12 12 0 5.303 3.438 9.8 8.205 11.385.6.113.82-.258.82-.577 0-.285-.01-1.04-.015-2.04-3.338.724-4.042-1.61-4.042-1.61C4.422 18.07 3.633 17.7 3.633 17.7c-1.087-.744.084-.729.084-.729 1.205.084 1.838 1.236 1.838 1.236 1.07 1.835 2.809 1.305 3.495.998.108-.776.417-1.305.76-1.605-2.665-.3-5.466-1.332-5.466-5.93 0-1.31.465-2.38 1.235-3.22-.135-.303-.54-1.523.105-3.176 0 0 1.005-.322 3.3 1.23.96-.267 1.98-.399 3-.405 1.02.006 2.04.138 3 .405 2.28-1.552 3.285-1.23 3.285-1.23.645 1.653.24 2.873.12 3.176.765.84 1.23 1.91 1.23 3.22 0 4.61-2.805 5.625-5.475 5.92.42.36.81 1.096.81 2.22 0 1.606-.015 2.896-.015 3.286 0 .315.21.69.825.57C20.565 22.092 24 17.592 24 12.297c0-6.627-5.373-12-12-12"/></svg></a><a class="VPSocialLink no-icon" href="#" aria-label="twitter" target="_blank" rel="noopener" data-v-7bc22406 data-v-f80f8133><svg role="img" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><title>Twitter</title><path d="M23.953 4.57a10 10 0 01-2.825.775 4.958 4.958 0 002.163-2.723c-.951.555-2.005.959-3.127 1.184a4.92 4.92 0 00-8.384 4.482C7.69 8.095 4.067 6.13 1.64 3.162a4.822 4.822 0 00-.666 2.475c0 1.71.87 3.213 2.188 4.096a4.904 4.904 0 01-2.228-.616v.06a4.923 4.923 0 003.946 4.827 4.996 4.996 0 01-2.212.085 4.936 4.936 0 004.604 3.417 9.867 9.867 0 01-6.102 2.105c-.39 0-.779-.023-1.17-.067a13.995 13.995 0 007.557 2.209c9.053 0 13.998-7.496 13.998-13.985 0-.21 0-.42-.015-.63A9.935 9.935 0 0024 4.59z"/></svg></a><a class="VPSocialLink no-icon" href="https://github.com/" aria-label target="_blank" rel="noopener" data-v-7bc22406 data-v-f80f8133><svg t="1676028692954" class="icon" ...</path></svg></a><!--]--></div></div></div><!--]--><!--]--></div></div></div><!--[--><!--]--><button type="button" class="VPNavBarHamburger hamburger" aria-label="mobile navigation" aria-expanded="false" aria-controls="VPNavScreen" data-v-0937f67c data-v-e5dd9c1c><span class="container" data-v-e5dd9c1c><span class="top" data-v-e5dd9c1c></span><span class="middle" data-v-e5dd9c1c></span><span class="bottom" data-v-e5dd9c1c></span></span></button></div></div></div></div><!----></header><div class="VPLocalNav reached-top" data-v-255ec12d data-v-5cfd5582><button class="menu" aria-expanded="false" aria-controls="VPSidebarNav" data-v-5cfd5582><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" viewbox="0 0 24 24" class="menu-icon" data-v-5cfd5582><path d="M17,11H3c-0.6,0-1-0.4-1-1s0.4-1,1-1h14c0.6,0,1,0.4,1,1S17.6,11,17,11z"></path><path d="M21,7H3C2.4,7,2,6.6,2,6s0.4-1,1-1h18c0.6,0,1,0.4,1,1S21.6,7,21,7z"></path><path d="M21,15H3c-0.6,0-1-0.4-1-1s0.4-1,1-1h18c0.6,0,1,0.4,1,1S21.6,15,21,15z"></path><path d="M17,19H3c-0.6,0-1-0.4-1-1s0.4-1,1-1h14c0.6,0,1,0.4,1,1S17.6,19,17,19z"></path></svg><span class="menu-text" data-v-5cfd5582>Menu</span></button><div class="VPLocalNavOutlineDropdown" style="--vp-vh:0px;" data-v-5cfd5582 data-v-18201f51><button data-v-18201f51>Return to top</button><!----></div></div><aside class="VPSidebar" data-v-255ec12d data-v-845b8fc6><div class="curtain" data-v-845b8fc6></div><nav class="nav" id="VPSidebarNav" aria-labelledby="sidebar-aria-label" tabindex="-1" data-v-845b8fc6><span class="visually-hidden" id="sidebar-aria-label" data-v-845b8fc6> Sidebar Navigation </span><!--[--><!--]--><!--[--><div class="group" data-v-845b8fc6><section class="VPSidebarItem level-0 collapsible collapsed" data-v-845b8fc6 data-v-9b797284><div class="item" role="button" tabindex="0" data-v-9b797284><div class="indicator" data-v-9b797284></div><h2 class="text" data-v-9b797284>Java</h2><div class="caret" role="button" aria-label="toggle section" tabindex="0" data-v-9b797284><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" viewbox="0 0 24 24" class="caret-icon" data-v-9b797284><path d="M9,19c-0.3,0-0.5-0.1-0.7-0.3c-0.4-0.4-0.4-1,0-1.4l5.3-5.3L8.3,6.7c-0.4-0.4-0.4-1,0-1.4s1-0.4,1.4,0l6,6c0.4,0.4,0.4,1,0,1.4l-6,6C9.5,18.9,9.3,19,9,19z"></path></svg></div></div><div class="items" data-v-9b797284><!--[--><div class="VPSidebarItem level-1 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/Java/Java%E5%9F%BA%E7%A1%80.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>Java基础</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/Java/Java%E6%96%B0%E7%89%B9%E6%80%A7.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>Java新特性</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/Java/Java%E8%BF%9B%E9%98%B6.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>Java进阶</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/Java/Java%E9%9B%86%E5%90%88.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>Java集合</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/Java/Java%E9%AB%98%E7%BA%A7.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>Java高级</p><!--]--></a><!----></div><!----></div><!--]--></div></section></div><div class="group" data-v-845b8fc6><section class="VPSidebarItem level-0 collapsible collapsed" data-v-845b8fc6 data-v-9b797284><div class="item" role="button" tabindex="0" data-v-9b797284><div class="indicator" data-v-9b797284></div><h2 class="text" data-v-9b797284>Linux</h2><div class="caret" role="button" aria-label="toggle section" tabindex="0" data-v-9b797284><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" viewbox="0 0 24 24" class="caret-icon" data-v-9b797284><path d="M9,19c-0.3,0-0.5-0.1-0.7-0.3c-0.4-0.4-0.4-1,0-1.4l5.3-5.3L8.3,6.7c-0.4-0.4-0.4-1,0-1.4s1-0.4,1.4,0l6,6c0.4,0.4,0.4,1,0,1.4l-6,6C9.5,18.9,9.3,19,9,19z"></path></svg></div></div><div class="items" data-v-9b797284><!--[--><div class="VPSidebarItem level-1 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/Linux/Linux%E5%9F%BA%E7%A1%80.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>Linux基础</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/Linux/Linux%E8%BF%9B%E9%98%B6.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>Linux新特性</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/Linux/Shell.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>Shell脚本</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/Linux/%E5%AE%9E%E7%94%A8%E8%84%9A%E6%9C%AC.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>实用脚本</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/Linux/%E8%BD%AF%E4%BB%B6%E9%83%A8%E7%BD%B2.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>软件部署</p><!--]--></a><!----></div><!----></div><!--]--></div></section></div><div class="group" data-v-845b8fc6><section class="VPSidebarItem level-0 collapsible collapsed" data-v-845b8fc6 data-v-9b797284><div class="item" role="button" tabindex="0" data-v-9b797284><div class="indicator" data-v-9b797284></div><h2 class="text" data-v-9b797284>Nginx</h2><div class="caret" role="button" aria-label="toggle section" tabindex="0" data-v-9b797284><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" viewbox="0 0 24 24" class="caret-icon" data-v-9b797284><path d="M9,19c-0.3,0-0.5-0.1-0.7-0.3c-0.4-0.4-0.4-1,0-1.4l5.3-5.3L8.3,6.7c-0.4-0.4-0.4-1,0-1.4s1-0.4,1.4,0l6,6c0.4,0.4,0.4,1,0,1.4l-6,6C9.5,18.9,9.3,19,9,19z"></path></svg></div></div><div class="items" data-v-9b797284><!--[--><div class="VPSidebarItem level-1 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/Nginx/%E5%9F%BA%E7%A1%80%E7%AF%87.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>基础篇</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/Nginx/%E8%BF%9B%E9%98%B6%E7%AF%87.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>进阶篇</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/Nginx/%E5%AE%9E%E6%88%98%E7%AF%87.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>实战篇</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/Nginx/%E9%9D%A2%E8%AF%95%E7%AF%87.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>面试篇</p><!--]--></a><!----></div><!----></div><!--]--></div></section></div><div class="group" data-v-845b8fc6><section class="VPSidebarItem level-0 collapsible collapsed" data-v-845b8fc6 data-v-9b797284><div class="item" role="button" tabindex="0" data-v-9b797284><div class="indicator" data-v-9b797284></div><h2 class="text" data-v-9b797284>SSM</h2><div class="caret" role="button" aria-label="toggle section" tabindex="0" data-v-9b797284><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" viewbox="0 0 24 24" class="caret-icon" data-v-9b797284><path d="M9,19c-0.3,0-0.5-0.1-0.7-0.3c-0.4-0.4-0.4-1,0-1.4l5.3-5.3L8.3,6.7c-0.4-0.4-0.4-1,0-1.4s1-0.4,1.4,0l6,6c0.4,0.4,0.4,1,0,1.4l-6,6C9.5,18.9,9.3,19,9,19z"></path></svg></div></div><div class="items" data-v-9b797284><!--[--><div class="VPSidebarItem level-1 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/SSM/Maven.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>Maven</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/SSM/Spring.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>Spring</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/SSM/SpringMVC.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>SpringMVC</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/SSM/SpringBatch.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>SpringBatch</p><!--]--></a><!----></div><!----></div><!--]--></div></section></div><div class="group" data-v-845b8fc6><section class="VPSidebarItem level-0 collapsible collapsed" data-v-845b8fc6 data-v-9b797284><div class="item" role="button" tabindex="0" data-v-9b797284><div class="indicator" data-v-9b797284></div><h2 class="text" data-v-9b797284>SpringBoot</h2><div class="caret" role="button" aria-label="toggle section" tabindex="0" data-v-9b797284><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" viewbox="0 0 24 24" class="caret-icon" data-v-9b797284><path d="M9,19c-0.3,0-0.5-0.1-0.7-0.3c-0.4-0.4-0.4-1,0-1.4l5.3-5.3L8.3,6.7c-0.4-0.4-0.4-1,0-1.4s1-0.4,1.4,0l6,6c0.4,0.4,0.4,1,0,1.4l-6,6C9.5,18.9,9.3,19,9,19z"></path></svg></div></div><div class="items" data-v-9b797284><!--[--><div class="VPSidebarItem level-1 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/3%E3%80%81SpringBoot/%E5%9F%BA%E7%A1%80%E7%AF%87.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>基础篇</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/3%E3%80%81SpringBoot/%E5%BA%94%E7%94%A8%E7%AF%87.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>应用篇</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/3%E3%80%81SpringBoot/%E6%96%B0%E7%89%B9%E6%80%A7.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>新特性</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/3%E3%80%81SpringBoot/%E8%BF%90%E7%BB%B4&amp;%E5%8E%9F%E7%90%86.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>运维&原理</p><!--]--></a><!----></div><!----></div><!--]--></div></section></div><div class="group" data-v-845b8fc6><section class="VPSidebarItem level-0 collapsible collapsed" data-v-845b8fc6 data-v-9b797284><div class="item" role="button" tabindex="0" data-v-9b797284><div class="indicator" data-v-9b797284></div><h2 class="text" data-v-9b797284>SpringCloud</h2><div class="caret" role="button" aria-label="toggle section" tabindex="0" data-v-9b797284><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" viewbox="0 0 24 24" class="caret-icon" data-v-9b797284><path d="M9,19c-0.3,0-0.5-0.1-0.7-0.3c-0.4-0.4-0.4-1,0-1.4l5.3-5.3L8.3,6.7c-0.4-0.4-0.4-1,0-1.4s1-0.4,1.4,0l6,6c0.4,0.4,0.4,1,0,1.4l-6,6C9.5,18.9,9.3,19,9,19z"></path></svg></div></div><div class="items" data-v-9b797284><!--[--><div class="VPSidebarItem level-1 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/4%E3%80%81%E5%BE%AE%E6%9C%8D%E5%8A%A1/%E8%BF%9B%E9%98%B6.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>SpringCloud</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/4%E3%80%81%E5%BE%AE%E6%9C%8D%E5%8A%A1/%E5%BF%85%E5%A4%87/Sentinel.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>Sentinel</p><!--]--></a><!----></div><!----></div><!--]--></div></section></div><div class="group" data-v-845b8fc6><section class="VPSidebarItem level-0 collapsible collapsed" data-v-845b8fc6 data-v-9b797284><div class="item" role="button" tabindex="0" data-v-9b797284><div class="indicator" data-v-9b797284></div><h2 class="text" data-v-9b797284>SpringSecurity</h2><div class="caret" role="button" aria-label="toggle section" tabindex="0" data-v-9b797284><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" viewbox="0 0 24 24" class="caret-icon" data-v-9b797284><path d="M9,19c-0.3,0-0.5-0.1-0.7-0.3c-0.4-0.4-0.4-1,0-1.4l5.3-5.3L8.3,6.7c-0.4-0.4-0.4-1,0-1.4s1-0.4,1.4,0l6,6c0.4,0.4,0.4,1,0,1.4l-6,6C9.5,18.9,9.3,19,9,19z"></path></svg></div></div><div class="items" data-v-9b797284><!--[--><div class="VPSidebarItem level-1 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/4%E3%80%81%E5%BE%AE%E6%9C%8D%E5%8A%A1/SpringSecurity/%E5%9F%BA%E7%A1%80%E7%AF%87.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>SpringSecurity基础篇</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/4%E3%80%81%E5%BE%AE%E6%9C%8D%E5%8A%A1/SpringSecurity/%E8%BF%9B%E9%98%B6%E7%AF%87.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>SpringSecurity进阶篇</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/4%E3%80%81%E5%BE%AE%E6%9C%8D%E5%8A%A1/SpringSecurity/%E9%AB%98%E7%BA%A7%E7%AF%87.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>SpringSecurity高级篇</p><!--]--></a><!----></div><!----></div><!--]--></div></section></div><div class="group" data-v-845b8fc6><section class="VPSidebarItem level-0 collapsible collapsed" data-v-845b8fc6 data-v-9b797284><div class="item" role="button" tabindex="0" data-v-9b797284><div class="indicator" data-v-9b797284></div><h2 class="text" data-v-9b797284>Mybatis & MybatisPlus</h2><div class="caret" role="button" aria-label="toggle section" tabindex="0" data-v-9b797284><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" viewbox="0 0 24 24" class="caret-icon" data-v-9b797284><path d="M9,19c-0.3,0-0.5-0.1-0.7-0.3c-0.4-0.4-0.4-1,0-1.4l5.3-5.3L8.3,6.7c-0.4-0.4-0.4-1,0-1.4s1-0.4,1.4,0l6,6c0.4,0.4,0.4,1,0,1.4l-6,6C9.5,18.9,9.3,19,9,19z"></path></svg></div></div><div class="items" data-v-9b797284><!--[--><div class="VPSidebarItem level-1 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/Mybatis&amp;MybatisPlus/Mybatis.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>Mybatis</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/Mybatis&amp;MybatisPlus/MybatisPlus.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>MybatisPlus</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/Mybatis&amp;MybatisPlus/JPA.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>JPA</p><!--]--></a><!----></div><!----></div><!--]--></div></section></div><div class="group" data-v-845b8fc6><section class="VPSidebarItem level-0 collapsible collapsed" data-v-845b8fc6 data-v-9b797284><div class="item" role="button" tabindex="0" data-v-9b797284><div class="indicator" data-v-9b797284></div><h2 class="text" data-v-9b797284>Git & ChatGPT</h2><div class="caret" role="button" aria-label="toggle section" tabindex="0" data-v-9b797284><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" viewbox="0 0 24 24" class="caret-icon" data-v-9b797284><path d="M9,19c-0.3,0-0.5-0.1-0.7-0.3c-0.4-0.4-0.4-1,0-1.4l5.3-5.3L8.3,6.7c-0.4-0.4-0.4-1,0-1.4s1-0.4,1.4,0l6,6c0.4,0.4,0.4,1,0,1.4l-6,6C9.5,18.9,9.3,19,9,19z"></path></svg></div></div><div class="items" data-v-9b797284><!--[--><div class="VPSidebarItem level-1 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/5%E3%80%81%E8%BF%90%E7%BB%B4/Git.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>Git</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/5%E3%80%81%E8%BF%90%E7%BB%B4/Github.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>Github</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/5%E3%80%81%E8%BF%90%E7%BB%B4/ChatGPT.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>ChatGPT</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/5%E3%80%81%E8%BF%90%E7%BB%B4/Jenkins.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>Jenkins</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/5%E3%80%81%E8%BF%90%E7%BB%B4/Netty.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>Netty</p><!--]--></a><!----></div><!----></div><!--]--></div></section></div><div class="group" data-v-845b8fc6><section class="VPSidebarItem level-0 collapsible collapsed" data-v-845b8fc6 data-v-9b797284><div class="item" role="button" tabindex="0" data-v-9b797284><div class="indicator" data-v-9b797284></div><h2 class="text" data-v-9b797284>数据库</h2><div class="caret" role="button" aria-label="toggle section" tabindex="0" data-v-9b797284><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" viewbox="0 0 24 24" class="caret-icon" data-v-9b797284><path d="M9,19c-0.3,0-0.5-0.1-0.7-0.3c-0.4-0.4-0.4-1,0-1.4l5.3-5.3L8.3,6.7c-0.4-0.4-0.4-1,0-1.4s1-0.4,1.4,0l6,6c0.4,0.4,0.4,1,0,1.4l-6,6C9.5,18.9,9.3,19,9,19z"></path></svg></div></div><div class="items" data-v-9b797284><!--[--><section class="VPSidebarItem level-1 collapsible collapsed" data-v-9b797284 data-v-9b797284><div class="item" role="button" tabindex="0" data-v-9b797284><div class="indicator" data-v-9b797284></div><h3 class="text" data-v-9b797284>MySQL</h3><div class="caret" role="button" aria-label="toggle section" tabindex="0" data-v-9b797284><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" viewbox="0 0 24 24" class="caret-icon" data-v-9b797284><path d="M9,19c-0.3,0-0.5-0.1-0.7-0.3c-0.4-0.4-0.4-1,0-1.4l5.3-5.3L8.3,6.7c-0.4-0.4-0.4-1,0-1.4s1-0.4,1.4,0l6,6c0.4,0.4,0.4,1,0,1.4l-6,6C9.5,18.9,9.3,19,9,19z"></path></svg></div></div><div class="items" data-v-9b797284><!--[--><div class="VPSidebarItem level-2 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/2%E3%80%81%E6%95%B0%E6%8D%AE%E5%BA%93/MySQL/MySQL%E6%A0%B8%E5%BF%83/%E5%9F%BA%E7%A1%80.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>MySQL基础</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-2 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/2%E3%80%81%E6%95%B0%E6%8D%AE%E5%BA%93/MySQL/MySQL%E6%A0%B8%E5%BF%83/%E8%BF%9B%E9%98%B6.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>MySQL进阶</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-2 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/2%E3%80%81%E6%95%B0%E6%8D%AE%E5%BA%93/MySQL/MySQL%E6%A0%B8%E5%BF%83/%E4%BC%98%E5%8C%96.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>MySQL优化</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-2 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/2%E3%80%81%E6%95%B0%E6%8D%AE%E5%BA%93/MySQL/MySQL%E6%A0%B8%E5%BF%83/%E8%AE%BE%E8%AE%A1.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>MySQL设计</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-2 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/2%E3%80%81%E6%95%B0%E6%8D%AE%E5%BA%93/MySQL/MySQL%E6%A0%B8%E5%BF%83/%E8%BF%90%E7%BB%B4.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>MySQL运维</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-2 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/2%E3%80%81%E6%95%B0%E6%8D%AE%E5%BA%93/MySQL/%E5%88%86%E5%BA%93%E5%88%86%E8%A1%A8.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>分库分表</p><!--]--></a><!----></div><!----></div><!--]--></div></section><section class="VPSidebarItem level-1 collapsible collapsed" data-v-9b797284 data-v-9b797284><div class="item" role="button" tabindex="0" data-v-9b797284><div class="indicator" data-v-9b797284></div><h3 class="text" data-v-9b797284>Redis</h3><div class="caret" role="button" aria-label="toggle section" tabindex="0" data-v-9b797284><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" viewbox="0 0 24 24" class="caret-icon" data-v-9b797284><path d="M9,19c-0.3,0-0.5-0.1-0.7-0.3c-0.4-0.4-0.4-1,0-1.4l5.3-5.3L8.3,6.7c-0.4-0.4-0.4-1,0-1.4s1-0.4,1.4,0l6,6c0.4,0.4,0.4,1,0,1.4l-6,6C9.5,18.9,9.3,19,9,19z"></path></svg></div></div><div class="items" data-v-9b797284><!--[--><div class="VPSidebarItem level-2 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/2%E3%80%81%E6%95%B0%E6%8D%AE%E5%BA%93/Redis/Redis%E5%9F%BA%E7%A1%80.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>Redis基础</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-2 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/2%E3%80%81%E6%95%B0%E6%8D%AE%E5%BA%93/Redis/Redis%E4%BC%98%E5%8C%96.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>Redis优化</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-2 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/2%E3%80%81%E6%95%B0%E6%8D%AE%E5%BA%93/Redis/Redis%E5%8E%9F%E7%90%86.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>Redis原理</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-2 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/2%E3%80%81%E6%95%B0%E6%8D%AE%E5%BA%93/Redis/Redis%E9%AB%98%E7%BA%A7.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>Redis高级</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-2 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/2%E3%80%81%E6%95%B0%E6%8D%AE%E5%BA%93/Redis/Redis%E5%AE%9E%E6%88%98.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>Redis实战</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-2 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/2%E3%80%81%E6%95%B0%E6%8D%AE%E5%BA%93/Redis/%E6%9C%AC%E5%9C%B0%E7%BC%93%E5%AD%98.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>本地缓存</p><!--]--></a><!----></div><!----></div><!--]--></div></section><section class="VPSidebarItem level-1 collapsible collapsed" data-v-9b797284 data-v-9b797284><div class="item" role="button" tabindex="0" data-v-9b797284><div class="indicator" data-v-9b797284></div><h3 class="text" data-v-9b797284>MongoDB</h3><div class="caret" role="button" aria-label="toggle section" tabindex="0" data-v-9b797284><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" viewbox="0 0 24 24" class="caret-icon" data-v-9b797284><path d="M9,19c-0.3,0-0.5-0.1-0.7-0.3c-0.4-0.4-0.4-1,0-1.4l5.3-5.3L8.3,6.7c-0.4-0.4-0.4-1,0-1.4s1-0.4,1.4,0l6,6c0.4,0.4,0.4,1,0,1.4l-6,6C9.5,18.9,9.3,19,9,19z"></path></svg></div></div><div class="items" data-v-9b797284><!--[--><div class="VPSidebarItem level-2 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/2%E3%80%81%E6%95%B0%E6%8D%AE%E5%BA%93/MongoDB/%E5%9F%BA%E7%A1%80.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>MongoDB基础</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-2 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/2%E3%80%81%E6%95%B0%E6%8D%AE%E5%BA%93/MongoDB/%E6%95%B4%E5%90%88.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>MongoDB进阶</p><!--]--></a><!----></div><!----></div><!--]--></div></section><section class="VPSidebarItem level-1 collapsible collapsed" data-v-9b797284 data-v-9b797284><div class="item" role="button" tabindex="0" data-v-9b797284><div class="indicator" data-v-9b797284></div><h3 class="text" data-v-9b797284>ElasticSearch</h3><div class="caret" role="button" aria-label="toggle section" tabindex="0" data-v-9b797284><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" viewbox="0 0 24 24" class="caret-icon" data-v-9b797284><path d="M9,19c-0.3,0-0.5-0.1-0.7-0.3c-0.4-0.4-0.4-1,0-1.4l5.3-5.3L8.3,6.7c-0.4-0.4-0.4-1,0-1.4s1-0.4,1.4,0l6,6c0.4,0.4,0.4,1,0,1.4l-6,6C9.5,18.9,9.3,19,9,19z"></path></svg></div></div><div class="items" data-v-9b797284><!--[--><div class="VPSidebarItem level-2 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/2%E3%80%81%E6%95%B0%E6%8D%AE%E5%BA%93/ElasticSearch/1%E3%80%81ES%E5%9F%BA%E7%A1%80.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>ES基础</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-2 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/2%E3%80%81%E6%95%B0%E6%8D%AE%E5%BA%93/ElasticSearch/3%E3%80%81ES%E9%AB%98%E7%BA%A7.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>ES高级</p><!--]--></a><!----></div><!----></div><!--]--></div></section><div class="VPSidebarItem level-1 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/2%E3%80%81%E6%95%B0%E6%8D%AE%E5%BA%93/influxdb.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>InfluxDB</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/2%E3%80%81%E6%95%B0%E6%8D%AE%E5%BA%93/Neo4j.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>Neo4j</p><!--]--></a><!----></div><!----></div><!--]--></div></section></div><div class="group" data-v-845b8fc6><section class="VPSidebarItem level-0 collapsible collapsed" data-v-845b8fc6 data-v-9b797284><div class="item" role="button" tabindex="0" data-v-9b797284><div class="indicator" data-v-9b797284></div><h2 class="text" data-v-9b797284>高并发 & 秒杀 & 分布式</h2><div class="caret" role="button" aria-label="toggle section" tabindex="0" data-v-9b797284><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" viewbox="0 0 24 24" class="caret-icon" data-v-9b797284><path d="M9,19c-0.3,0-0.5-0.1-0.7-0.3c-0.4-0.4-0.4-1,0-1.4l5.3-5.3L8.3,6.7c-0.4-0.4-0.4-1,0-1.4s1-0.4,1.4,0l6,6c0.4,0.4,0.4,1,0,1.4l-6,6C9.5,18.9,9.3,19,9,19z"></path></svg></div></div><div class="items" data-v-9b797284><!--[--><div class="VPSidebarItem level-1 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/%E4%B8%89%E9%AB%98/%E5%88%86%E5%B8%83%E5%BC%8F.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>分布式理论</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/4%E3%80%81%E5%BE%AE%E6%9C%8D%E5%8A%A1/%E5%BF%85%E5%A4%87/%E5%88%86%E5%B8%83%E5%BC%8F%E9%94%81.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>分布式锁</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/%E4%B8%89%E9%AB%98/%E7%A7%92%E6%9D%80.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>秒杀</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/%E4%B8%89%E9%AB%98/%E9%AB%98%E5%8F%AF%E7%94%A8.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>高可用</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/%E4%B8%89%E9%AB%98/%E9%AB%98%E5%B9%B6%E5%8F%91.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>高并发</p><!--]--></a><!----></div><!----></div><!--]--></div></section></div><div class="group" data-v-845b8fc6><section class="VPSidebarItem level-0 collapsible collapsed" data-v-845b8fc6 data-v-9b797284><div class="item" role="button" tabindex="0" data-v-9b797284><div class="indicator" data-v-9b797284></div><h2 class="text" data-v-9b797284>云原生</h2><div class="caret" role="button" aria-label="toggle section" tabindex="0" data-v-9b797284><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" viewbox="0 0 24 24" class="caret-icon" data-v-9b797284><path d="M9,19c-0.3,0-0.5-0.1-0.7-0.3c-0.4-0.4-0.4-1,0-1.4l5.3-5.3L8.3,6.7c-0.4-0.4-0.4-1,0-1.4s1-0.4,1.4,0l6,6c0.4,0.4,0.4,1,0,1.4l-6,6C9.5,18.9,9.3,19,9,19z"></path></svg></div></div><div class="items" data-v-9b797284><!--[--><div class="VPSidebarItem level-1 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/%E4%BA%91%E5%8E%9F%E7%94%9F/Docker.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>Docker</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/%E4%BA%91%E5%8E%9F%E7%94%9F/K8S.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>K8S</p><!--]--></a><!----></div><!----></div><!--]--></div></section></div><div class="group" data-v-845b8fc6><section class="VPSidebarItem level-0 collapsible has-active" data-v-845b8fc6 data-v-9b797284><div class="item" role="button" tabindex="0" data-v-9b797284><div class="indicator" data-v-9b797284></div><h2 class="text" data-v-9b797284>可视化 & 监控</h2><div class="caret" role="button" aria-label="toggle section" tabindex="0" data-v-9b797284><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" viewbox="0 0 24 24" class="caret-icon" data-v-9b797284><path d="M9,19c-0.3,0-0.5-0.1-0.7-0.3c-0.4-0.4-0.4-1,0-1.4l5.3-5.3L8.3,6.7c-0.4-0.4-0.4-1,0-1.4s1-0.4,1.4,0l6,6c0.4,0.4,0.4,1,0,1.4l-6,6C9.5,18.9,9.3,19,9,19z"></path></svg></div></div><div class="items" data-v-9b797284><!--[--><div class="VPSidebarItem level-1 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/%E5%8F%AF%E8%A7%86%E5%8C%96%20&amp;%20%E7%9B%91%E6%8E%A7/%E7%9B%91%E6%8E%A7%E5%9F%BA%E7%A1%80.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>监控基础</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/%E5%8F%AF%E8%A7%86%E5%8C%96%20&amp;%20%E7%9B%91%E6%8E%A7/%E7%9B%91%E6%8E%A7%E8%BF%9B%E9%98%B6.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>监控进阶</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/%E5%8F%AF%E8%A7%86%E5%8C%96%20&amp;%20%E7%9B%91%E6%8E%A7/%E5%8F%AF%E8%A7%86%E5%8C%96%E5%A4%A7%E5%B1%8F.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>可视化大屏</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/%E5%8F%AF%E8%A7%86%E5%8C%96%20&amp;%20%E7%9B%91%E6%8E%A7/Zabbix.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>Zabbix</p><!--]--></a><!----></div><!----></div><!--]--></div></section></div><div class="group" data-v-845b8fc6><section class="VPSidebarItem level-0 collapsible collapsed" data-v-845b8fc6 data-v-9b797284><div class="item" role="button" tabindex="0" data-v-9b797284><div class="indicator" data-v-9b797284></div><h2 class="text" data-v-9b797284>学前端</h2><div class="caret" role="button" aria-label="toggle section" tabindex="0" data-v-9b797284><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" viewbox="0 0 24 24" class="caret-icon" data-v-9b797284><path d="M9,19c-0.3,0-0.5-0.1-0.7-0.3c-0.4-0.4-0.4-1,0-1.4l5.3-5.3L8.3,6.7c-0.4-0.4-0.4-1,0-1.4s1-0.4,1.4,0l6,6c0.4,0.4,0.4,1,0,1.4l-6,6C9.5,18.9,9.3,19,9,19z"></path></svg></div></div><div class="items" data-v-9b797284><!--[--><section class="VPSidebarItem level-1 collapsible collapsed" data-v-9b797284 data-v-9b797284><div class="item" role="button" tabindex="0" data-v-9b797284><div class="indicator" data-v-9b797284></div><h3 class="text" data-v-9b797284>HTML+CSS</h3><div class="caret" role="button" aria-label="toggle section" tabindex="0" data-v-9b797284><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" viewbox="0 0 24 24" class="caret-icon" data-v-9b797284><path d="M9,19c-0.3,0-0.5-0.1-0.7-0.3c-0.4-0.4-0.4-1,0-1.4l5.3-5.3L8.3,6.7c-0.4-0.4-0.4-1,0-1.4s1-0.4,1.4,0l6,6c0.4,0.4,0.4,1,0,1.4l-6,6C9.5,18.9,9.3,19,9,19z"></path></svg></div></div><div class="items" data-v-9b797284><!--[--><div class="VPSidebarItem level-2 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/1%E3%80%81%E5%AD%A6%E5%89%8D%E7%AB%AF/1%E3%80%81HTML+CSS/HTML%E5%9F%BA%E7%A1%80.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>HTML基础</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-2 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/1%E3%80%81%E5%AD%A6%E5%89%8D%E7%AB%AF/1%E3%80%81HTML+CSS/CSS%E5%9F%BA%E7%A1%80.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>CSS基础</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-2 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/1%E3%80%81%E5%AD%A6%E5%89%8D%E7%AB%AF/1%E3%80%81HTML+CSS/%E7%BD%91%E9%A1%B5%E8%BF%9B%E9%98%B6.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>网页进阶</p><!--]--></a><!----></div><!----></div><!--]--></div></section><section class="VPSidebarItem level-1 collapsible collapsed" data-v-9b797284 data-v-9b797284><div class="item" role="button" tabindex="0" data-v-9b797284><div class="indicator" data-v-9b797284></div><h3 class="text" data-v-9b797284>JS+TS</h3><div class="caret" role="button" aria-label="toggle section" tabindex="0" data-v-9b797284><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" viewbox="0 0 24 24" class="caret-icon" data-v-9b797284><path d="M9,19c-0.3,0-0.5-0.1-0.7-0.3c-0.4-0.4-0.4-1,0-1.4l5.3-5.3L8.3,6.7c-0.4-0.4-0.4-1,0-1.4s1-0.4,1.4,0l6,6c0.4,0.4,0.4,1,0,1.4l-6,6C9.5,18.9,9.3,19,9,19z"></path></svg></div></div><div class="items" data-v-9b797284><!--[--><div class="VPSidebarItem level-2 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/1%E3%80%81%E5%AD%A6%E5%89%8D%E7%AB%AF/2%E3%80%81JS+TS/JS%20%E5%9F%BA%E7%A1%80.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>JS基础</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-2 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/1%E3%80%81%E5%AD%A6%E5%89%8D%E7%AB%AF/2%E3%80%81JS+TS/JS%20%E8%BF%9B%E9%98%B6.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>JS进阶</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-2 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/1%E3%80%81%E5%AD%A6%E5%89%8D%E7%AB%AF/2%E3%80%81JS+TS/ES6%20%E5%9F%BA%E7%A1%80.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>ES6基础</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-2 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/1%E3%80%81%E5%AD%A6%E5%89%8D%E7%AB%AF/2%E3%80%81JS+TS/ES6%20%E8%BF%9B%E9%98%B6.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>ES6进阶</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-2 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/1%E3%80%81%E5%AD%A6%E5%89%8D%E7%AB%AF/2%E3%80%81JS+TS/TypeScript.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>TS基础</p><!--]--></a><!----></div><!----></div><!--]--></div></section><section class="VPSidebarItem level-1 collapsible collapsed" data-v-9b797284 data-v-9b797284><div class="item" role="button" tabindex="0" data-v-9b797284><div class="indicator" data-v-9b797284></div><h3 class="text" data-v-9b797284>NodeJS</h3><div class="caret" role="button" aria-label="toggle section" tabindex="0" data-v-9b797284><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" viewbox="0 0 24 24" class="caret-icon" data-v-9b797284><path d="M9,19c-0.3,0-0.5-0.1-0.7-0.3c-0.4-0.4-0.4-1,0-1.4l5.3-5.3L8.3,6.7c-0.4-0.4-0.4-1,0-1.4s1-0.4,1.4,0l6,6c0.4,0.4,0.4,1,0,1.4l-6,6C9.5,18.9,9.3,19,9,19z"></path></svg></div></div><div class="items" data-v-9b797284><!--[--><div class="VPSidebarItem level-2 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/1%E3%80%81%E5%AD%A6%E5%89%8D%E7%AB%AF/4%E3%80%81Node/%E5%9F%BA%E7%A1%80%E7%AF%87.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>Node基础</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-2 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/1%E3%80%81%E5%AD%A6%E5%89%8D%E7%AB%AF/4%E3%80%81Node/%E8%BF%9B%E9%98%B6%E7%AF%87.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>Node进阶</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-2 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/1%E3%80%81%E5%AD%A6%E5%89%8D%E7%AB%AF/4%E3%80%81Node/%E9%A1%B9%E7%9B%AE%E5%AE%9E%E6%88%98.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>项目实战</p><!--]--></a><!----></div><!----></div><!--]--></div></section><section class="VPSidebarItem level-1 collapsible collapsed" data-v-9b797284 data-v-9b797284><div class="item" role="button" tabindex="0" data-v-9b797284><div class="indicator" data-v-9b797284></div><h3 class="text" data-v-9b797284>Vue</h3><div class="caret" role="button" aria-label="toggle section" tabindex="0" data-v-9b797284><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" viewbox="0 0 24 24" class="caret-icon" data-v-9b797284><path d="M9,19c-0.3,0-0.5-0.1-0.7-0.3c-0.4-0.4-0.4-1,0-1.4l5.3-5.3L8.3,6.7c-0.4-0.4-0.4-1,0-1.4s1-0.4,1.4,0l6,6c0.4,0.4,0.4,1,0,1.4l-6,6C9.5,18.9,9.3,19,9,19z"></path></svg></div></div><div class="items" data-v-9b797284><!--[--><div class="VPSidebarItem level-2 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/1%E3%80%81%E5%AD%A6%E5%89%8D%E7%AB%AF/3%E3%80%81Vue/Vue3/Vue3%E8%BF%9B%E9%98%B6.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>Vue3进阶</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-2 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/1%E3%80%81%E5%AD%A6%E5%89%8D%E7%AB%AF/3%E3%80%81Vue/Vue3/Vue3%E9%AB%98%E7%BA%A7.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>Vue3高级</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-2 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/1%E3%80%81%E5%AD%A6%E5%89%8D%E7%AB%AF/3%E3%80%81Vue/Vue3/Vue3%E6%96%B0%E8%AF%AD%E6%B3%95.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>Vue3新语法</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-2 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/1%E3%80%81%E5%AD%A6%E5%89%8D%E7%AB%AF/3%E3%80%81Vue/Vue2/Vue2%E9%A1%B9%E7%9B%AE.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>项目实战</p><!--]--></a><!----></div><!----></div><!--]--></div></section><section class="VPSidebarItem level-1 collapsible collapsed" data-v-9b797284 data-v-9b797284><div class="item" role="button" tabindex="0" data-v-9b797284><div class="indicator" data-v-9b797284></div><h3 class="text" data-v-9b797284>小程序</h3><div class="caret" role="button" aria-label="toggle section" tabindex="0" data-v-9b797284><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" viewbox="0 0 24 24" class="caret-icon" data-v-9b797284><path d="M9,19c-0.3,0-0.5-0.1-0.7-0.3c-0.4-0.4-0.4-1,0-1.4l5.3-5.3L8.3,6.7c-0.4-0.4-0.4-1,0-1.4s1-0.4,1.4,0l6,6c0.4,0.4,0.4,1,0,1.4l-6,6C9.5,18.9,9.3,19,9,19z"></path></svg></div></div><div class="items" data-v-9b797284><!--[--><div class="VPSidebarItem level-2 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/1%E3%80%81%E5%AD%A6%E5%89%8D%E7%AB%AF/5%E3%80%81%E5%B0%8F%E7%A8%8B%E5%BA%8F/%E5%BE%AE%E4%BF%A1%E5%B0%8F%E7%A8%8B%E5%BA%8F.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>小程序基础</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-2 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/1%E3%80%81%E5%AD%A6%E5%89%8D%E7%AB%AF/5%E3%80%81%E5%B0%8F%E7%A8%8B%E5%BA%8F/%E5%B0%8F%E7%A8%8B%E5%BA%8F%E4%BC%98%E5%8C%96.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>小程序优化</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-2 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/1%E3%80%81%E5%AD%A6%E5%89%8D%E7%AB%AF/5%E3%80%81%E5%B0%8F%E7%A8%8B%E5%BA%8F/uniapp.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>uniapp</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-2 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/1%E3%80%81%E5%AD%A6%E5%89%8D%E7%AB%AF/5%E3%80%81%E5%B0%8F%E7%A8%8B%E5%BA%8F/%E5%B0%8F%E7%A8%8B%E5%BA%8F%E9%A1%B9%E7%9B%AE.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>项目实战</p><!--]--></a><!----></div><!----></div><!--]--></div></section><!--]--></div></section></div><div class="group" data-v-845b8fc6><section class="VPSidebarItem level-0 collapsible collapsed" data-v-845b8fc6 data-v-9b797284><div class="item" role="button" tabindex="0" data-v-9b797284><div class="indicator" data-v-9b797284></div><h2 class="text" data-v-9b797284>计算机基础</h2><div class="caret" role="button" aria-label="toggle section" tabindex="0" data-v-9b797284><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" viewbox="0 0 24 24" class="caret-icon" data-v-9b797284><path d="M9,19c-0.3,0-0.5-0.1-0.7-0.3c-0.4-0.4-0.4-1,0-1.4l5.3-5.3L8.3,6.7c-0.4-0.4-0.4-1,0-1.4s1-0.4,1.4,0l6,6c0.4,0.4,0.4,1,0,1.4l-6,6C9.5,18.9,9.3,19,9,19z"></path></svg></div></div><div class="items" data-v-9b797284><!--[--><div class="VPSidebarItem level-1 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/%E8%AE%A1%E7%AE%97%E6%9C%BA%E5%9F%BA%E7%A1%80/%E6%95%B0%E6%8D%AE%E7%BB%93%E6%9E%84/%E5%9F%BA%E7%A1%80%E7%AF%87.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>数据结构</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/%E8%AE%A1%E7%AE%97%E6%9C%BA%E5%9F%BA%E7%A1%80/%E8%AE%A1%E7%AE%97%E6%9C%BA%E5%9F%BA%E7%A1%80/%E6%93%8D%E4%BD%9C%E7%B3%BB%E7%BB%9F.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>操作系统</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/%E8%AE%A1%E7%AE%97%E6%9C%BA%E5%9F%BA%E7%A1%80/%E8%AE%BE%E8%AE%A1%E6%A8%A1%E5%BC%8F/%E5%9F%BA%E7%A1%80%E7%AF%87.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>设计模式</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/%E8%AE%A1%E7%AE%97%E6%9C%BA%E5%9F%BA%E7%A1%80/%E8%AE%A1%E7%AE%97%E6%9C%BA%E7%BD%91%E7%BB%9C/%E7%BD%91%E7%BB%9C%E5%9F%BA%E7%A1%80.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>计算机网络</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/%E8%AE%A1%E7%AE%97%E6%9C%BA%E5%9F%BA%E7%A1%80/%E8%AE%BE%E8%AE%A1%E6%A8%A1%E5%BC%8F/UML.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>UML</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/%E8%AE%A1%E7%AE%97%E6%9C%BA%E5%9F%BA%E7%A1%80/%E7%AE%97%E6%B3%95/LeetCode.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>LeetCode</p><!--]--></a><!----></div><!----></div><!--]--></div></section></div><div class="group" data-v-845b8fc6><section class="VPSidebarItem level-0 collapsible collapsed" data-v-845b8fc6 data-v-9b797284><div class="item" role="button" tabindex="0" data-v-9b797284><div class="indicator" data-v-9b797284></div><h2 class="text" data-v-9b797284>项目实战</h2><div class="caret" role="button" aria-label="toggle section" tabindex="0" data-v-9b797284><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" viewbox="0 0 24 24" class="caret-icon" data-v-9b797284><path d="M9,19c-0.3,0-0.5-0.1-0.7-0.3c-0.4-0.4-0.4-1,0-1.4l5.3-5.3L8.3,6.7c-0.4-0.4-0.4-1,0-1.4s1-0.4,1.4,0l6,6c0.4,0.4,0.4,1,0,1.4l-6,6C9.5,18.9,9.3,19,9,19z"></path></svg></div></div><div class="items" data-v-9b797284><!--[--><section class="VPSidebarItem level-1 collapsible collapsed" data-v-9b797284 data-v-9b797284><div class="item" role="button" tabindex="0" data-v-9b797284><div class="indicator" data-v-9b797284></div><h3 class="text" data-v-9b797284>云尚办公</h3><div class="caret" role="button" aria-label="toggle section" tabindex="0" data-v-9b797284><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" viewbox="0 0 24 24" class="caret-icon" data-v-9b797284><path d="M9,19c-0.3,0-0.5-0.1-0.7-0.3c-0.4-0.4-0.4-1,0-1.4l5.3-5.3L8.3,6.7c-0.4-0.4-0.4-1,0-1.4s1-0.4,1.4,0l6,6c0.4,0.4,0.4,1,0,1.4l-6,6C9.5,18.9,9.3,19,9,19z"></path></svg></div></div><div class="items" data-v-9b797284><!--[--><div class="VPSidebarItem level-2 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/%E9%A1%B9%E7%9B%AE%E5%AE%9E%E6%88%98/%E4%BA%91%E5%B0%9A%E5%8A%9E%E5%85%AC/%E5%9F%BA%E7%A1%80%E7%AF%87.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>基础篇</p><!--]--></a><!----></div><!----></div><!--]--></div></section><section class="VPSidebarItem level-1 collapsible collapsed" data-v-9b797284 data-v-9b797284><div class="item" role="button" tabindex="0" data-v-9b797284><div class="indicator" data-v-9b797284></div><h3 class="text" data-v-9b797284>小兔鲜</h3><div class="caret" role="button" aria-label="toggle section" tabindex="0" data-v-9b797284><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" viewbox="0 0 24 24" class="caret-icon" data-v-9b797284><path d="M9,19c-0.3,0-0.5-0.1-0.7-0.3c-0.4-0.4-0.4-1,0-1.4l5.3-5.3L8.3,6.7c-0.4-0.4-0.4-1,0-1.4s1-0.4,1.4,0l6,6c0.4,0.4,0.4,1,0,1.4l-6,6C9.5,18.9,9.3,19,9,19z"></path></svg></div></div><div class="items" data-v-9b797284><!--[--><div class="VPSidebarItem level-2 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/%E9%A1%B9%E7%9B%AE%E5%AE%9E%E6%88%98/%E5%B0%8F%E5%85%94%E9%B2%9C/%E5%9F%BA%E7%A1%80%E7%AF%87.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>基础篇</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-2 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/%E9%A1%B9%E7%9B%AE%E5%AE%9E%E6%88%98/%E5%B0%8F%E5%85%94%E9%B2%9C/%E8%BF%9B%E9%98%B6%E7%AF%871.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>进阶篇1</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-2 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/%E9%A1%B9%E7%9B%AE%E5%AE%9E%E6%88%98/%E5%B0%8F%E5%85%94%E9%B2%9C/%E8%BF%9B%E9%98%B6%E7%AF%872.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>进阶篇2</p><!--]--></a><!----></div><!----></div><!--]--></div></section><section class="VPSidebarItem level-1 collapsible collapsed" data-v-9b797284 data-v-9b797284><div class="item" role="button" tabindex="0" data-v-9b797284><div class="indicator" data-v-9b797284></div><h3 class="text" data-v-9b797284>地图</h3><div class="caret" role="button" aria-label="toggle section" tabindex="0" data-v-9b797284><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" viewbox="0 0 24 24" class="caret-icon" data-v-9b797284><path d="M9,19c-0.3,0-0.5-0.1-0.7-0.3c-0.4-0.4-0.4-1,0-1.4l5.3-5.3L8.3,6.7c-0.4-0.4-0.4-1,0-1.4s1-0.4,1.4,0l6,6c0.4,0.4,0.4,1,0,1.4l-6,6C9.5,18.9,9.3,19,9,19z"></path></svg></div></div><div class="items" data-v-9b797284><!--[--><div class="VPSidebarItem level-2 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/%E9%A1%B9%E7%9B%AE%E5%AE%9E%E6%88%98/%E7%99%BE%E5%BA%A6%E5%9C%B0%E5%9B%BE/%E5%9F%BA%E7%A1%80%E7%AF%87.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>基础篇</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-2 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/%E9%A1%B9%E7%9B%AE%E5%AE%9E%E6%88%98/%E7%99%BE%E5%BA%A6%E5%9C%B0%E5%9B%BE/%E8%BF%9B%E9%98%B6%E7%AF%87.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>进阶篇</p><!--]--></a><!----></div><!----></div><!--]--></div></section><section class="VPSidebarItem level-1 collapsible collapsed" data-v-9b797284 data-v-9b797284><div class="item" role="button" tabindex="0" data-v-9b797284><div class="indicator" data-v-9b797284></div><h3 class="text" data-v-9b797284>苍穹外卖</h3><div class="caret" role="button" aria-label="toggle section" tabindex="0" data-v-9b797284><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" viewbox="0 0 24 24" class="caret-icon" data-v-9b797284><path d="M9,19c-0.3,0-0.5-0.1-0.7-0.3c-0.4-0.4-0.4-1,0-1.4l5.3-5.3L8.3,6.7c-0.4-0.4-0.4-1,0-1.4s1-0.4,1.4,0l6,6c0.4,0.4,0.4,1,0,1.4l-6,6C9.5,18.9,9.3,19,9,19z"></path></svg></div></div><div class="items" data-v-9b797284><!--[--><div class="VPSidebarItem level-2 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/%E9%A1%B9%E7%9B%AE%E5%AE%9E%E6%88%98/%E8%8B%8D%E7%A9%B9%E5%A4%96%E5%8D%96/%E8%BF%9B%E9%98%B6%E7%AF%87.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>进阶篇</p><!--]--></a><!----></div><!----></div><!--]--></div></section><section class="VPSidebarItem level-1 collapsible collapsed" data-v-9b797284 data-v-9b797284><div class="item" role="button" tabindex="0" data-v-9b797284><div class="indicator" data-v-9b797284></div><h3 class="text" data-v-9b797284>黑马头条</h3><div class="caret" role="button" aria-label="toggle section" tabindex="0" data-v-9b797284><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" viewbox="0 0 24 24" class="caret-icon" data-v-9b797284><path d="M9,19c-0.3,0-0.5-0.1-0.7-0.3c-0.4-0.4-0.4-1,0-1.4l5.3-5.3L8.3,6.7c-0.4-0.4-0.4-1,0-1.4s1-0.4,1.4,0l6,6c0.4,0.4,0.4,1,0,1.4l-6,6C9.5,18.9,9.3,19,9,19z"></path></svg></div></div><div class="items" data-v-9b797284><!--[--><div class="VPSidebarItem level-2 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/%E9%A1%B9%E7%9B%AE%E5%AE%9E%E6%88%98/%E9%BB%91%E9%A9%AC%E5%A4%B4%E6%9D%A1/%E5%9F%BA%E7%A1%80%E7%AF%87.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>基础篇</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-2 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/%E9%A1%B9%E7%9B%AE%E5%AE%9E%E6%88%98/%E9%BB%91%E9%A9%AC%E5%A4%B4%E6%9D%A1/%E8%BF%9B%E9%98%B6%E7%AF%87.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>进阶篇</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-2 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/%E9%A1%B9%E7%9B%AE%E5%AE%9E%E6%88%98/%E9%BB%91%E9%A9%AC%E5%A4%B4%E6%9D%A1/%E8%BF%9B%E9%98%B6%E7%AF%872.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>进阶篇2</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-2 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/%E9%A1%B9%E7%9B%AE%E5%AE%9E%E6%88%98/%E9%BB%91%E9%A9%AC%E5%A4%B4%E6%9D%A1/%E9%AB%98%E7%BA%A7%E7%AF%87.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>高级篇</p><!--]--></a><!----></div><!----></div><!--]--></div></section><div class="VPSidebarItem level-1 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/%E9%A1%B9%E7%9B%AE%E5%AE%9E%E6%88%98/%E6%94%AF%E4%BB%98.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>支付</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/%E9%A1%B9%E7%9B%AE%E5%AE%9E%E6%88%98/%E9%A1%B9%E7%9B%AE%E6%8E%A8%E8%8D%90.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>项目推荐</p><!--]--></a><!----></div><!----></div><!--]--></div></section></div><div class="group" data-v-845b8fc6><section class="VPSidebarItem level-0" data-v-845b8fc6 data-v-9b797284><!----><div class="items" data-v-9b797284><!--[--><div class="VPSidebarItem level-1 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/team.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>团队成员</p><!--]--></a><!----></div><!----></div><!--]--></div></section></div><!--]--><!--[--><!--]--></nav></aside><div class="VPContent has-sidebar" id="VPContent" data-v-255ec12d data-v-669faec9><div class="VPDoc has-sidebar has-aside" data-v-669faec9 data-v-6b87e69f><!--[--><!--]--><div class="container" data-v-6b87e69f><div class="aside" data-v-6b87e69f><div class="aside-curtain" data-v-6b87e69f></div><div class="aside-container" data-v-6b87e69f><div class="aside-content" data-v-6b87e69f><div class="VPDocAside" data-v-6b87e69f data-v-3f215769><!--[--><!--]--><!--[--><!--]--><div class="VPDocAsideOutline" data-v-3f215769 data-v-ff0f39c8><div class="content" data-v-ff0f39c8><div class="outline-marker" data-v-ff0f39c8></div><div class="outline-title" data-v-ff0f39c8>On this page</div><nav aria-labelledby="doc-outline-aria-label" data-v-ff0f39c8><span class="visually-hidden" id="doc-outline-aria-label" data-v-ff0f39c8> Table of Contents for current page </span><ul class="root" data-v-ff0f39c8 data-v-d0ee3533><!--[--><!--]--></ul></nav></div></div><!--[--><!--]--><div class="spacer" data-v-3f215769></div><!--[--><!--]--><!----><!--[--><!--]--><!--[--><!--]--></div></div></div></div><div class="content" data-v-6b87e69f><div class="content-container" data-v-6b87e69f><!--[--><!--]--><!----><main class="main" data-v-6b87e69f><div style="position:relative;" class="vp-doc _notebook_%E5%8F%AF%E8%A7%86%E5%8C%96%20&amp;%20%E7%9B%91%E6%8E%A7_%E7%9B%91%E6%8E%A7%E8%BF%9B%E9%98%B6" data-v-6b87e69f><div><h1 id="应用安装" tabindex="-1">应用安装 <a class="header-anchor" href="#应用安装" aria-label="Permalink to &quot;应用安装&quot;">​</a></h1><h2 id="rabbitmq、nginx、mongo、redis" tabindex="-1">rabbitmq、nginx、mongo、redis <a class="header-anchor" href="#rabbitmq、nginx、mongo、redis" aria-label="Permalink to &quot;rabbitmq、nginx、mongo、redis&quot;">​</a></h2><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#FFCB6B;">mkdir</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">/data/docker-compose</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-p</span></span>
<span class="line"><span style="color:#82AAFF;">cd</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">/data/docker-compose</span></span></code></pre></div><div class="language-yml"><button title="Copy Code" class="copy"></button><span class="lang">yml</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#F07178;">version</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&#39;</span><span style="color:#C3E88D;">3</span><span style="color:#89DDFF;">&#39;</span></span>
<span class="line"><span style="color:#F07178;">services</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#F07178;">redis</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">image</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">redis:5</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">container_name</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">redis</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">command</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">redis-server --requirepass 123456 --maxmemory 512mb</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">restart</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">always</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">volumes</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">/data/redis/data:/data</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">ports</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">6379:6379</span></span>
<span class="line"></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#F07178;">nginx</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">image</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">nginx:1.21.6</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">container_name</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">nginx</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">restart</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">always</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">volumes</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">/data/nginx/conf.d:/etc/nginx/conf.d</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">/data/nginx/html:/usr/share/nginx/html</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">/data/nginx/log:/var/log/nginx</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">ports</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">80:80</span></span>
<span class="line"></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#F07178;">rabbitmq</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">image</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">rabbitmq:3.7.15-management</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">container_name</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">rabbitmq</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">restart</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">always</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">volumes</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">/data/rabbitmq/data:/var/lib/rabbitmq</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">/data/rabbitmq/log:/var/log/rabbitmq</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">ports</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">5672:5672</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">15672:15672</span></span>
<span class="line"></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#F07178;">mongo</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">image</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">mongo:4.2.5</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">container_name</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">mongo</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">restart</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">always</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">volumes</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">/data/mongo/db:/data/db</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">ports</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">27017:27017</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">command</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">[</span><span style="color:#C3E88D;">--auth</span><span style="color:#89DDFF;">]</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">environment</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">MONGO_INITDB_ROOT_USERNAME</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">root</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">MONGO_INITDB_ROOT_PASSWORD</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#F78C6C;">123456</span></span></code></pre></div><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#676E95;font-style:italic;"># 运⾏,STATUS列全部为up 为正常</span></span>
<span class="line"><span style="color:#FFCB6B;">docker-compose</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">up</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-d</span></span>
<span class="line"><span style="color:#FFCB6B;">docker</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">ps</span></span></code></pre></div><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304271548761.png" alt="image-20230427154851699" style="zoom:80%;"><h2 id="mysql" tabindex="-1">MySQL <a class="header-anchor" href="#mysql" aria-label="Permalink to &quot;MySQL&quot;">​</a></h2><p>为了快速测试，我使⽤docker-compose安装mysql，当然也可以⾃⾏安装</p><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#FFCB6B;">mkdir</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-p</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">/data/mysql</span><span style="color:#A6ACCD;"> </span></span>
<span class="line"><span style="color:#82AAFF;">cd</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">/data/mysql</span></span>
<span class="line"><span style="color:#FFCB6B;">vim</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">docker-compose.yml</span></span></code></pre></div><div class="language-yml"><button title="Copy Code" class="copy"></button><span class="lang">yml</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#F07178;">version</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&#39;</span><span style="color:#C3E88D;">3.1</span><span style="color:#89DDFF;">&#39;</span></span>
<span class="line"><span style="color:#F07178;">services</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#F07178;">db</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">image</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">mysql:8.0.23</span><span style="color:#A6ACCD;"> </span><span style="color:#676E95;font-style:italic;"># 指定MySQL 8.0.26版本</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">restart</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">always</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">container_name</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">mysql</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">environment</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">TZ</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">Asia/Shanghai</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">LANG</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">en_US.UTF-8</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">MYSQL_ROOT_PASSWORD</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#F78C6C;">123456</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">command</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">        </span><span style="color:#C3E88D;">--default-authentication-plugin=mysql_native_password</span></span>
<span class="line"><span style="color:#A6ACCD;">        </span><span style="color:#C3E88D;">--character-set-server=utf8mb4</span></span>
<span class="line"><span style="color:#A6ACCD;">        </span><span style="color:#C3E88D;">--collation-server=utf8mb4_general_ci</span></span>
<span class="line"><span style="color:#A6ACCD;">        </span><span style="color:#C3E88D;">--lower_case_table_names=1</span></span>
<span class="line"><span style="color:#A6ACCD;">        </span><span style="color:#C3E88D;">--performance_schema=1</span></span>
<span class="line"><span style="color:#A6ACCD;">        </span><span style="color:#C3E88D;">--sql-mode=&quot;&quot;</span></span>
<span class="line"><span style="color:#A6ACCD;">        </span><span style="color:#C3E88D;">--skip-log-bin</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">volumes</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">/data/mysql/conf:/etc/mysql/conf.d</span><span style="color:#A6ACCD;"> </span><span style="color:#676E95;font-style:italic;">#配置⽂件挂载</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">/data/mysql/data:/var/lib/mysql</span><span style="color:#A6ACCD;"> </span><span style="color:#676E95;font-style:italic;">#数据⽂件挂载</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">ports</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">3306:3306</span></span></code></pre></div><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#676E95;font-style:italic;"># 运⾏</span></span>
<span class="line"><span style="color:#FFCB6B;">docker-compose</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">up</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-d</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 检查,STATUS列全部为up 为正常</span></span>
<span class="line"><span style="color:#FFCB6B;">docker</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">ps</span></span></code></pre></div><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#676E95;font-style:italic;"># 登陆mysql</span></span>
<span class="line"><span style="color:#FFCB6B;">docker</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">exec</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-it</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">mysql</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">mysql</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-uroot</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-p</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 输⼊密码：123456，创建</span></span>
<span class="line"><span style="color:#FFCB6B;">CREATE</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">USER</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&#39;</span><span style="color:#C3E88D;">exporter</span><span style="color:#89DDFF;">&#39;</span><span style="color:#C3E88D;">@</span><span style="color:#89DDFF;">&#39;</span><span style="color:#C3E88D;">%</span><span style="color:#89DDFF;">&#39;</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">IDENTIFIED</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">BY</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&#39;</span><span style="color:#C3E88D;">password</span><span style="color:#89DDFF;">&#39;</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">WITH</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">MAX_USER_CONNECTIONS</span><span style="color:#A6ACCD;"> </span><span style="color:#F78C6C;">3</span><span style="color:#89DDFF;">;</span></span>
<span class="line"><span style="color:#FFCB6B;">GRANT</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">PROCESS,</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">REPLICATION</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">CLIENT,</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">SELECT</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">ON</span><span style="color:#A6ACCD;"> </span><span style="color:#A6ACCD;">*</span><span style="color:#C3E88D;">.</span><span style="color:#A6ACCD;">*</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">TO</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&#39;</span><span style="color:#C3E88D;">exporter</span><span style="color:#89DDFF;">&#39;</span><span style="color:#C3E88D;">@</span><span style="color:#89DDFF;">&#39;</span><span style="color:#C3E88D;">%</span><span style="color:#89DDFF;">&#39;</span><span style="color:#89DDFF;">;</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 验证</span></span>
<span class="line"><span style="color:#FFCB6B;">docker</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">exec</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-it</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">mysql</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">mysql</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-uexporter</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-p</span></span></code></pre></div><h2 id="刷新配置" tabindex="-1">刷新配置 <a class="header-anchor" href="#刷新配置" aria-label="Permalink to &quot;刷新配置&quot;">​</a></h2><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#676E95;font-style:italic;"># 检查规则写的是否正确</span></span>
<span class="line"><span style="color:#82AAFF;">cd</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">/opt/module/prometheus-2.29.1</span></span>
<span class="line"><span style="color:#FFCB6B;">./promtool</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">check</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">rules</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">rules/linux.yml</span></span>
<span class="line"><span style="color:#FFCB6B;">curl</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-X</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">POST</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">http://node1:9090/-/reload</span></span>
<span class="line"><span style="color:#FFCB6B;">curl</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-X</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">POST</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">http://node1:9093/-/reload</span></span></code></pre></div><h1 id="linux" tabindex="-1">Linux <a class="header-anchor" href="#linux" aria-label="Permalink to &quot;Linux&quot;">​</a></h1><blockquote><p>使用<code>node_explorer</code>可以暴露Linux系统的指标信息，然后Prometheus就可以通过定时扫描的方式获取并存储指标信息了。下载<code>node_explorer</code>的安装包，下载地址：<a href="https://prometheus.io/download/#node_exporter" target="_blank" rel="noreferrer">https://prometheus.io/download/#node_exporter</a></p></blockquote><h2 id="二进制安装" tabindex="-1">二进制安装 <a class="header-anchor" href="#二进制安装" aria-label="Permalink to &quot;二进制安装&quot;">​</a></h2><p>这次我们直接把<code>node_explorer</code>安装到Linux服务器上（如果使用Docker容器安装，监控的会是Docker容器的指标信息）,将下载的安装包解压到指定目录，并修改文件夹名称：</p><h3 id="下载解压改名" tabindex="-1">下载解压改名 <a class="header-anchor" href="#下载解压改名" aria-label="Permalink to &quot;下载解压改名&quot;">​</a></h3><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#676E95;font-style:italic;"># 下载，解压，改名</span></span>
<span class="line"><span style="color:#FFCB6B;">wget</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">https://github.com/prometheus/node_exporter/releases/download/v1.5.0/node_exporter-1.5.0.linux-amd64.tar.gz</span></span>
<span class="line"><span style="color:#FFCB6B;">tar</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-zxvf</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">node_exporter-1.5.0.linux-amd64.tar.gz</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-C</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">/opt/module</span></span>
<span class="line"><span style="color:#FFCB6B;">mv</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">node_exporter-1.5.0.linux-amd64</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">node_exporter1.5.0</span></span></code></pre></div><p>进入解压目录，使用如下命令运行<code>node_explorer</code>，服务将运行在<code>9100</code>端口上；</p><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#82AAFF;">cd</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">node_exporter</span></span>
<span class="line"><span style="color:#FFCB6B;">./node_exporter</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&gt;</span><span style="color:#C3E88D;">log.file</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">2&gt;&amp;1</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&amp;</span></span></code></pre></div><h3 id="设置为开机自启" tabindex="-1">设置为开机自启 <a class="header-anchor" href="#设置为开机自启" aria-label="Permalink to &quot;设置为开机自启&quot;">​</a></h3><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#FFCB6B;">sudo</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">vim</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">/usr/lib/systemd/system/node_exporter.service</span></span></code></pre></div><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#89DDFF;">[</span><span style="color:#A6ACCD;">Unit</span><span style="color:#89DDFF;">]</span></span>
<span class="line"><span style="color:#A6ACCD;">Description</span><span style="color:#89DDFF;">=</span><span style="color:#C3E88D;">node_export</span></span>
<span class="line"><span style="color:#A6ACCD;">Documentation</span><span style="color:#89DDFF;">=</span><span style="color:#C3E88D;">https://github.com/prometheus/node_exporter</span></span>
<span class="line"><span style="color:#A6ACCD;">After</span><span style="color:#89DDFF;">=</span><span style="color:#C3E88D;">network.target</span></span>
<span class="line"><span style="color:#89DDFF;">[</span><span style="color:#A6ACCD;">Service</span><span style="color:#89DDFF;">]</span></span>
<span class="line"><span style="color:#A6ACCD;">Type</span><span style="color:#89DDFF;">=</span><span style="color:#C3E88D;">simple</span></span>
<span class="line"><span style="color:#A6ACCD;">User</span><span style="color:#89DDFF;">=</span><span style="color:#C3E88D;">root</span></span>
<span class="line"><span style="color:#A6ACCD;">ExecStart</span><span style="color:#89DDFF;">=</span><span style="color:#A6ACCD;"> </span><span style="color:#FFCB6B;">/opt/module/node_exporter1.5.0/node_exporter</span></span>
<span class="line"><span style="color:#A6ACCD;">Restart</span><span style="color:#89DDFF;">=</span><span style="color:#C3E88D;">on-failure</span></span>
<span class="line"><span style="color:#89DDFF;">[</span><span style="color:#A6ACCD;">Install</span><span style="color:#89DDFF;">]</span></span>
<span class="line"><span style="color:#A6ACCD;">WantedBy</span><span style="color:#89DDFF;">=</span><span style="color:#C3E88D;">multi-user.target</span></span></code></pre></div><h3 id="启动运行" tabindex="-1">启动运行 <a class="header-anchor" href="#启动运行" aria-label="Permalink to &quot;启动运行&quot;">​</a></h3><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#FFCB6B;">systemctl</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">daemon-reload</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 设为开机自启动（所有机器都执行）</span></span>
<span class="line"><span style="color:#FFCB6B;">sudo</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">systemctl</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">enable</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">node_exporter.service</span></span>
<span class="line"><span style="color:#FFCB6B;">sudo</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">systemctl</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">start</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">node_exporter.service</span></span>
<span class="line"><span style="color:#FFCB6B;">sudo</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">systemctl</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">stop</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">node_exporter.service</span></span></code></pre></div><p>使用访问获取指标信息接口，获取到信息表示运行成功；</p><p>访问：<a href="http://192.168.22.130:9100/metrics" target="_blank" rel="noreferrer">http://192.168.22.130:9100/metrics</a></p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2022.8.30/202209090942448.png" alt="image-20220909094212400" style="zoom:80%;"><h2 id="docker安装⭐" tabindex="-1">Docker安装⭐ <a class="header-anchor" href="#docker安装⭐" aria-label="Permalink to &quot;Docker安装⭐&quot;">​</a></h2><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#FFCB6B;">mkdir</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">/data/node_exporter</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-p</span></span>
<span class="line"><span style="color:#82AAFF;">cd</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">/data/node_exporter</span></span></code></pre></div><div class="language-yml"><button title="Copy Code" class="copy"></button><span class="lang">yml</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#C3E88D;">cat &gt; docker-compose.yaml &lt;&lt;&quot;EOF&quot;</span></span>
<span class="line"><span style="color:#F07178;">version</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&#39;</span><span style="color:#C3E88D;">3.3</span><span style="color:#89DDFF;">&#39;</span></span>
<span class="line"><span style="color:#F07178;">services</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#F07178;">node_exporter</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">image</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">prom/node-exporter:v1.5.0</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">container_name</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">node-exporter</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">restart</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">always</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">volumes</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">/proc:/host/proc:ro</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">/sys:/host/sys:ro</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">/:/rootfs:ro</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">command</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&#39;</span><span style="color:#C3E88D;">--path.procfs=/host/proc</span><span style="color:#89DDFF;">&#39;</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&#39;</span><span style="color:#C3E88D;">--path.sysfs=/host/sys</span><span style="color:#89DDFF;">&#39;</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&#39;</span><span style="color:#C3E88D;">--collector.filesystem.ignored-mount-points=^/(sys|proc|dev|host|etc|rootfs/var/lib/docker)($$|/)</span><span style="color:#89DDFF;">&#39;</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">ports</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&#39;</span><span style="color:#C3E88D;">9100:9100</span><span style="color:#89DDFF;">&#39;</span></span>
<span class="line"><span style="color:#C3E88D;">EOF</span></span></code></pre></div><div class="language-"><button title="Copy Code" class="copy"></button><span class="lang"></span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#A6ACCD;">docker-compose up -d</span></span>
<span class="line"><span style="color:#A6ACCD;">docker ps</span></span>
<span class="line"><span style="color:#A6ACCD;">docker logs -f node-exporter</span></span></code></pre></div><p><a href="http://192.168.88.101:9100/metrics" target="_blank" rel="noreferrer">http://192.168.88.101:9100/metrics</a></p><h2 id="prometheus配置" tabindex="-1">prometheus配置 <a class="header-anchor" href="#prometheus配置" aria-label="Permalink to &quot;prometheus配置&quot;">​</a></h2><p>接下来修改Prometheus的配置文件<code>prometheus.yml</code>，创建一个任务定时扫描<code>node_explorer</code>暴露的指标信息；上面配置过了，注意：要求prometheus是启动的</p><div class="language-yml"><button title="Copy Code" class="copy"></button><span class="lang">yml</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#F07178;">scrape_configs</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#F07178;">job_name</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">prometheus</span><span style="color:#89DDFF;">&quot;</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">static_configs</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#F07178;">targets</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">[</span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">localhost:9090</span><span style="color:#89DDFF;">&quot;</span><span style="color:#89DDFF;">]</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#F07178;">job_name</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&#39;</span><span style="color:#C3E88D;">pushgateway</span><span style="color:#89DDFF;">&#39;</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">static_configs</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#F07178;">targets</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">[</span><span style="color:#89DDFF;">&#39;</span><span style="color:#C3E88D;">localhost:9091</span><span style="color:#89DDFF;">&#39;</span><span style="color:#89DDFF;">]</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#F07178;">job_name</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&#39;</span><span style="color:#C3E88D;">linux监控</span><span style="color:#89DDFF;">&#39;</span><span style="color:#A6ACCD;"> </span><span style="color:#676E95;font-style:italic;"># targets可以监控多个目标，就算目标不存活也无所谓</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">static_configs</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#F07178;">targets</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">[</span><span style="color:#89DDFF;">&#39;</span><span style="color:#C3E88D;">node1:9100</span><span style="color:#89DDFF;">&#39;</span><span style="color:#89DDFF;">,</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&#39;</span><span style="color:#C3E88D;">node2:9100</span><span style="color:#89DDFF;">&#39;</span><span style="color:#89DDFF;">,</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&#39;</span><span style="color:#C3E88D;">node3:9100</span><span style="color:#89DDFF;">&#39;</span><span style="color:#89DDFF;">]</span></span></code></pre></div><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#676E95;font-style:italic;"># 检查配置文件是否有问题</span></span>
<span class="line"><span style="color:#FFCB6B;">./promtool</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">check</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">config</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">prometheus.yml</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 热更新配置文件</span></span>
<span class="line"><span style="color:#FFCB6B;">curl</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-X</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">POST</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">http://node1:9090/-/reload</span></span></code></pre></div><p>prometheus：<a href="http://node1:9090" target="_blank" rel="noreferrer">http://node1:9090</a></p><p>grafana：<a href="http://node1:3000" target="_blank" rel="noreferrer">http://node1:3000</a></p><h2 id="常用监控指标" tabindex="-1">常用监控指标 <a class="header-anchor" href="#常用监控指标" aria-label="Permalink to &quot;常用监控指标&quot;">​</a></h2><h3 id="cpu采集" tabindex="-1">cpu采集 <a class="header-anchor" href="#cpu采集" aria-label="Permalink to &quot;cpu采集&quot;">​</a></h3><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#FFCB6B;">node_cpu_seconds_total</span></span></code></pre></div><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304271505538.png" alt="image-20230427150504480" style="zoom:80%;"><h3 id="内存采集" tabindex="-1">内存采集 <a class="header-anchor" href="#内存采集" aria-label="Permalink to &quot;内存采集&quot;">​</a></h3><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#676E95;font-style:italic;"># /proc/meminfo⽂件</span></span>
<span class="line"><span style="color:#FFCB6B;">node_memory_</span></span></code></pre></div><table><thead><tr><th>名称</th><th>含义</th><th>备注</th></tr></thead><tbody><tr><td>node_memory_MemTotal_bytes</td><td>内存总大小</td><td>单位字节，/1024/1024=MB，/1024/1024/1024=GB</td></tr><tr><td>node_memory_MemAvailable_bytes</td><td>空闲可使用内存大小</td><td></td></tr><tr><td>node_memory_MemFree_bytes</td><td>空闲物理内存大小</td><td></td></tr><tr><td>node_memory_SwapFree_bytes</td><td>swap内存空闲大小</td><td></td></tr><tr><td>node_memory_SwapTotal_bytes</td><td>swap内存总大小</td><td></td></tr></tbody></table><h3 id="磁盘采集" tabindex="-1">磁盘采集 <a class="header-anchor" href="#磁盘采集" aria-label="Permalink to &quot;磁盘采集&quot;">​</a></h3><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#FFCB6B;">node_disk_</span></span></code></pre></div><h3 id="文件系统采集" tabindex="-1">⽂件系统采集 <a class="header-anchor" href="#文件系统采集" aria-label="Permalink to &quot;⽂件系统采集&quot;">​</a></h3><div class="language-"><button title="Copy Code" class="copy"></button><span class="lang"></span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#A6ACCD;">node_filesystem_</span></span></code></pre></div><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304271510056.png" alt="image-20230427151048992" style="zoom:80%;"><h3 id="网络采集" tabindex="-1">⽹络采集 <a class="header-anchor" href="#网络采集" aria-label="Permalink to &quot;⽹络采集&quot;">​</a></h3><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#FFCB6B;">node_network_</span></span></code></pre></div><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304271511738.png" alt="image-20230427151112689" style="zoom:80%;"><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304271511113.png" alt="image-20230427151123065" style="zoom:80%;"><h2 id="触发器配置" tabindex="-1">触发器配置 <a class="header-anchor" href="#触发器配置" aria-label="Permalink to &quot;触发器配置&quot;">​</a></h2><p>prometheus.yml</p><div class="language-yml"><button title="Copy Code" class="copy"></button><span class="lang">yml</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#F07178;">alerting</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#F07178;">alertmanagers</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#F07178;">static_configs</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">        </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#F07178;">targets</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">          </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">localhost:9093</span></span>
<span class="line"></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># Load rules once and periodically evaluate them according to the global &#39;evaluation_interval&#39;.</span></span>
<span class="line"><span style="color:#F07178;">rule_files</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">rules/*.yml</span><span style="color:#89DDFF;">&quot;</span></span></code></pre></div><p>rules/linux.yml</p><div class="language-yml"><button title="Copy Code" class="copy"></button><span class="lang">yml</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#F07178;">groups</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#F07178;">name</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">node-exporter</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#F07178;">rules</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#F07178;">alert</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">HostOutOfMemory</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">expr</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">node_memory_MemAvailable_bytes / node_memory_MemTotal_bytes * 100 &lt; 10</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">for</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">2m</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">labels</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">severity</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">warning</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">annotations</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">summary</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">主机内存不足，实例: {{ $labels.instance }}</span><span style="color:#89DDFF;">&quot;</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">description</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">内存可用率 &lt; 10%，当前值：{{ $value }}</span><span style="color:#89DDFF;">&quot;</span></span>
<span class="line"></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#F07178;">alert</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">HostMemoryUnderMemoryPressure</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">expr</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">rate(node_vmstat_pgmajfault[1m]) &gt; 1000</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">for</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">2m</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">labels</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">severity</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">warning</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">annotations</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">summary</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">内存压力不足，实例: {{ $labels.instance }}</span><span style="color:#89DDFF;">&quot;</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">description</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">节点内存压力大。重大页面错误率高，当前值为：{{ $value }}</span><span style="color:#89DDFF;">&quot;</span></span>
<span class="line"></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#F07178;">alert</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">HostUnusualNetworkThroughputIn</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">expr</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">sum by (instance) (rate(node_network_receive_bytes_total[2m])) / 1024 / 1024 &gt; 100</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">for</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">5m</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">labels</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">severity</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">warning</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">annotations</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">summary</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">异常流入网络吞吐量，实例: {{ $labels.instance }}</span><span style="color:#89DDFF;">&quot;</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">description</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">网络流入流量 &gt; 100 MB/s，当前值：{{ $value }}</span><span style="color:#89DDFF;">&quot;</span></span>
<span class="line"></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#F07178;">alert</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">HostUnusualNetworkThroughputOut</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">expr</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">sum by (instance) (rate(node_network_transmit_bytes_total[2m])) / 1024 / 1024 &gt; 100</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">for</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">5m</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">labels</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">severity</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">warning</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">annotations</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">summary</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">异常流出网络吞吐量，实例: {{ $labels.instance }}</span><span style="color:#89DDFF;">&quot;</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">description</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">网络流出流量 &gt; 100 MB/s，当前值为：{{ $value }}</span><span style="color:#89DDFF;">&quot;</span></span>
<span class="line"></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#F07178;">alert</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">HostUnusualDiskReadRate</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">expr</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">sum by (instance) (rate(node_disk_read_bytes_total[2m])) / 1024 / 1024 &gt; 50</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">for</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">5m</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">labels</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">severity</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">warning</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">annotations</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">summary</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">异常磁盘读取，实例: {{ $labels.instance }}</span><span style="color:#89DDFF;">&quot;</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">description</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">磁盘读取 &gt; 50 MB/s，当前值：{{ $value }}</span><span style="color:#89DDFF;">&quot;</span></span>
<span class="line"></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#F07178;">alert</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">HostUnusualDiskWriteRate</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">expr</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">sum by (instance) (rate(node_disk_written_bytes_total[2m])) / 1024 / 1024 &gt; 50</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">for</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">2m</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">labels</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">severity</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">warning</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">annotations</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">summary</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">异常磁盘写入，实例: {{ $labels.instance }}</span><span style="color:#89DDFF;">&quot;</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">description</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">磁盘写入 &gt; 50 MB/s，当前值：{{ $value }}</span><span style="color:#89DDFF;">&quot;</span></span>
<span class="line"></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#F07178;">alert</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">HostOutOfDiskSpace</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">expr</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">(node_filesystem_avail_bytes * 100) / node_filesystem_size_bytes &lt; 10 and ON (instance, device, mountpoint) node_filesystem_readonly == 0</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">for</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">2m</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">labels</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">severity</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">warning</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">annotations</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">summary</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">磁盘空间不足告警，实例: {{ $labels.instance }}</span><span style="color:#89DDFF;">&quot;</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">description</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">剩余磁盘空间 &lt; 10%，当前值：{{ $value }}</span><span style="color:#89DDFF;">&quot;</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#F07178;">alert</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">HostDiskWillFillIn24Hours</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">expr</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">(node_filesystem_avail_bytes * 100) / node_filesystem_size_bytes &lt; 10 and on (instance, device, mountpoint) predict_linear(node_filesystem_avail_bytes{fstype!~&quot;tmpfs&quot;}[1h], 24 * 3600) &lt; 0 and on (instance, device, mountpoint) node_filesystem_readonly == 0</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">for</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">2m</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">labels</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">severity</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">warning</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">annotations</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">summary</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">磁盘空间将在24小时内耗尽，实例: {{ $labels.instance }}</span><span style="color:#89DDFF;">&quot;</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">description</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">以当前写入速率预计磁盘空间将在24小时内耗尽，当前值：{{ $value }}</span><span style="color:#89DDFF;">&quot;</span></span>
<span class="line"></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#F07178;">alert</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">HostOutOfInodes</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">expr</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">node_filesystem_files_free{mountpoint=&quot;/&quot;}/node_filesystem_files{mountpoint=&quot;/&quot;} * 100 &lt; 10 and on (instance, device, mountpoint) node_filesystem_readonly{mountpoint=&quot;/&quot;} == 0</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">for</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">2m</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">labels</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">severity</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">warning</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">annotations</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">summary</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">磁盘Inodes不足，实例: {{ $labels.instance }}</span><span style="color:#89DDFF;">&quot;</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">description</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">剩余磁盘inodes &lt; 10%，当前值：{{ $value }}</span><span style="color:#89DDFF;">&quot;</span></span>
<span class="line"></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#F07178;">alert</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">HostUnusualDiskReadLatency</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">expr</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">rate(node_disk_read_time_seconds_total[1m])/rate(node_disk_reads_completed_total[1m]) &gt; 0.1 and rate(node_disk_reads_completed_total[1m]) &gt; 0</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">for</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">2m</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">labels</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">severity</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">warning</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">annotations</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">summary</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">异常磁盘读取延迟，实例: {{ $labels.instance }}</span><span style="color:#89DDFF;">&quot;</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">description</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">磁盘读取延迟 &gt; 100ms，当前值：{{ $value }}</span><span style="color:#89DDFF;">&quot;</span></span>
<span class="line"></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#F07178;">alert</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">HostUnusualDiskWriteLatency</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">expr</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">rate(node_disk_write_time_seconds_total[1m])/rate(node_disk_writes_completed_total[1m]) &gt; 0.1 and rate(node_disk_writes_completed_total[1m]) &gt; 0</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">for</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">2m</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">labels</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">severity</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">warning</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">annotations</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">summary</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">异常磁盘写入延迟，实例: {{ $labels.instance }}</span><span style="color:#89DDFF;">&quot;</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">description</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">磁盘写入延迟 &gt; 100ms，当前值：{{ $value }}</span><span style="color:#89DDFF;">&quot;</span></span>
<span class="line"></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#F07178;">alert</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">high_load</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">expr</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">node_load1 &gt; 4</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">for</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">2m</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">labels</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">severity</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">page</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">annotations</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">summary</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">CPU1分钟负载过高，实例: {{ $labels.instance }}</span><span style="color:#89DDFF;">&quot;</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">description</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">CPU1分钟负载 &gt; 4，已经持续2分钟。当前值为：{{ $value }}</span><span style="color:#89DDFF;">&quot;</span></span>
<span class="line"></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#F07178;">alert</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">HostCpuIsUnderUtilized</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">expr</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">100 - (avg by (instance) (rate(node_cpu_seconds_total{mode=&quot;idle&quot;}[2m])) * 100) &gt; 80</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">for</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">1m</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">labels</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">severity</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">warning</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">annotations</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">summary</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">CPU负载高，实例: {{ $labels.instance }}</span><span style="color:#89DDFF;">&quot;</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">description</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">cpu负载&gt; 80%，当前值：{{ $value }}</span><span style="color:#89DDFF;">&quot;</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#F07178;">alert</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">HostCpuStealNoisyNeighbor</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">expr</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">avg by(instance) (rate(node_cpu_seconds_total{mode=&quot;steal&quot;}[5m])) * 100 &gt; 10</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">for</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">0m</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">labels</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">severity</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">warning</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">annotations</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">summary</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">CPU窃取率异常,实例:{{ $labels.instance }}</span><span style="color:#89DDFF;">&quot;</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">description</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">CPU 窃取率 &gt; 10%。 嘈杂的邻居正在扼杀 VM 性能，或者 Spot 实例可能失去信⽤，当前值：{{ $value }}</span><span style="color:#89DDFF;">&quot;</span></span>
<span class="line"></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#F07178;">alert</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">HostSwapIsFillingUp</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">expr</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">(1 - (node_memory_SwapFree_bytes / node_memory_SwapTotal_bytes)) * 100 &gt; 80</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">for</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">2m</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">labels</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">severity</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">warning</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">annotations</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">summary</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">磁盘swap空间使⽤率异常,实例:{{ $labels.instance }}</span><span style="color:#89DDFF;">&quot;</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">description</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">磁盘swap空间使⽤率&gt;80%</span><span style="color:#89DDFF;">&quot;</span></span>
<span class="line"></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#F07178;">alert</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">HostNetworkReceiveErrors</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">expr</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">rate(node_network_receive_errs_total[2m]) / rate(node_network_receive_packets_total[2m]) &gt; 0.01</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">for</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">2m</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">labels</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">severity</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">warning</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">annotations</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">summary</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">异常⽹络接收错误,实例:{{ $labels.instance }}</span><span style="color:#89DDFF;">&quot;</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">description</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">⽹卡{{ $labels.device }}在过去2分钟接收{{ $value }}个错误</span><span style="color:#89DDFF;">&quot;</span></span>
<span class="line"></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#F07178;">alert</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">HostNetworkTransmitErrors</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">expr</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">rate(node_network_transmit_errs_total[2m]) /   rate(node_network_transmit_packets_total[2m]) &gt; 0.01</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">for</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">2m</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">labels</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">severity</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">warning</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">annotations</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">summary</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">异常⽹络传输错误,实例:{{ $labels.instance }}</span><span style="color:#89DDFF;">&quot;</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">description</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">⽹卡{{ $labels.device }}在过去2分钟传输{{ $value }}个错误</span><span style="color:#89DDFF;">&quot;</span></span>
<span class="line"></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#F07178;">alert</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">HostNetworkInterfaceSaturated</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">expr</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">(rate(node_network_receive_bytes_total{device!~&quot;^tap.*&quot;}[1m]) +   rate(node_network_transmit_bytes_total{device!~&quot;^tap.*&quot;}[1m])) /   node_network_speed_bytes{device!~&quot;^tap.*&quot;} &gt; 0.8 &lt; 10000</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">for</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">1m</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">labels</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">severity</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">warning</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">annotations</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">summary</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">异常⽹络接⼝饱和,实例:{{ $labels.instance }}</span><span style="color:#89DDFF;">&quot;</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">description</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">⽹卡{{ $labels.device }}正在超载，当前值{{ $value }}</span><span style="color:#89DDFF;">&quot;</span></span>
<span class="line"></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#F07178;">alert</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">HostConntrackLimit</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">expr</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">node_nf_conntrack_entries / node_nf_conntrack_entries_limit &gt; 0.8</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">for</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">5m</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">labels</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">severity</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">warning</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">annotations</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">summary</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">异常连接数,实例:{{ $labels.instance }}</span><span style="color:#89DDFF;">&quot;</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">description</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">连接数过⼤，当前连接数：{{ $value }}</span><span style="color:#89DDFF;">&quot;</span></span>
<span class="line"></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#F07178;">alert</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">HostClockSkew</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">expr</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">(node_timex_offset_seconds &gt; 0.05 and deriv(node_timex_offset_seconds[5m]) &gt;= 0) or   (node_timex_offset_seconds &lt; -0.05 and deriv(node_timex_offset_seconds[5m]) &lt;= 0)</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">for</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">2m</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">labels</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">severity</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">warning</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">annotations</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">summary</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">异常时钟偏差,实例:{{ $labels.instance }}</span><span style="color:#89DDFF;">&quot;</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">description</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">检测到时钟偏差，时钟不同步。值为：{{ $value }}</span><span style="color:#89DDFF;">&quot;</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#F07178;">alert</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">HostClockNotSynchronising</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">expr</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">min_over_time(node_timex_sync_status[1m]) == 0 and node_timex_maxerror_seconds &gt;= 16</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">for</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">2m</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">labels</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">severity</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">warning</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">annotations</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">summary</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">时钟不同步,实例:{{ $labels.instance }}</span><span style="color:#89DDFF;">&quot;</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">description</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">时钟不同步</span><span style="color:#89DDFF;">&quot;</span></span></code></pre></div><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#676E95;font-style:italic;"># 检查规则写的是否正确</span></span>
<span class="line"><span style="color:#FFCB6B;">./promtool</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">check</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">rules</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">rules/linux.yml</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 热更新配置文件</span></span>
<span class="line"><span style="color:#FFCB6B;">curl</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-X</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">POST</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">http://node1:9090/-/reload</span></span></code></pre></div><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304271519334.png" alt="image-20230427151905258" style="zoom:80%;"><h2 id="dashboard" tabindex="-1">DashBoard <a class="header-anchor" href="#dashboard" aria-label="Permalink to &quot;DashBoard&quot;">​</a></h2><p>可以去Grafana的仪表盘市场下载一个Dashboard，市场地址：<a href="https://grafana.com/grafana/dashboards" target="_blank" rel="noreferrer">https://grafana.com/grafana/dashboards</a></p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2022.8.30/202209082159052.png" alt="image-20220908215906930" style="zoom:80%;"><p>这里选择了<code>Node Exporter Full</code>这个仪表盘，记住它的ID：<a href="https://grafana.com/grafana/dashboards/1860" target="_blank" rel="noreferrer">https://grafana.com/grafana/dashboards/1860</a></p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2022.5.13/202205181605390.png" alt="image-20220518160519337" style="zoom:80%;"><p>选择导入Dashboard并输入ID，最后点击<code>Load</code>即可；</p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2022.5.13/202205181605777.png" alt="image-20220518160530729" style="zoom:80%;"><ul><li>选择数据源为Prometheus，最后点击<code>Import</code>；</li></ul><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2022.5.13/202205181605008.png" alt="image-20220518160543962" style="zoom:80%;"><p>导入成功后就可以在Grafana中看到实时监控信息了，是不是够炫酷！</p><p>注意：<code>如果没数据，选择右上角的时间，Last 5 minutes，选择越小越容易显示数据</code></p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2022.5.13/202205181606337.png" alt="image-20220518160602272" style="zoom:80%;"><p>如果之前就导入成功了，那么就直接进去看把</p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304271540030.png" alt="image-20230427154000949" style="zoom:80%;"><h1 id="mysql-1" tabindex="-1">MySQL <a class="header-anchor" href="#mysql-1" aria-label="Permalink to &quot;MySQL&quot;">​</a></h1><p>下载地址：<a href="https://github.com/prometheus/mysqld_exporter/releases" target="_blank" rel="noreferrer">https://github.com/prometheus/mysqld_exporter/releases</a></p><h2 id="docker安装⭐-1" tabindex="-1">Docker安装⭐ <a class="header-anchor" href="#docker安装⭐-1" aria-label="Permalink to &quot;Docker安装⭐&quot;">​</a></h2><p><strong>docker-compose</strong>运⾏</p><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#FFCB6B;">mkdir</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">/data/mysqld_exporter</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-p</span></span>
<span class="line"><span style="color:#82AAFF;">cd</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">/data/mysqld_exporter</span></span></code></pre></div><blockquote><p>注意：必须使用mysql新用户连接，不能使用root连接，root连接获取不到数据</p></blockquote><div class="language-yml"><button title="Copy Code" class="copy"></button><span class="lang">yml</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#F07178;">version</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&#39;</span><span style="color:#C3E88D;">3.3</span><span style="color:#89DDFF;">&#39;</span></span>
<span class="line"><span style="color:#F07178;">services</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#F07178;">mysqld-exporter</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">image</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">prom/mysqld-exporter</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">container_name</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">mysqld-exporter</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">restart</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">always</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">command</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&#39;</span><span style="color:#C3E88D;">--collect.info_schema.processlist</span><span style="color:#89DDFF;">&#39;</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&#39;</span><span style="color:#C3E88D;">--collect.info_schema.innodb_metrics</span><span style="color:#89DDFF;">&#39;</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&#39;</span><span style="color:#C3E88D;">--collect.info_schema.tablestats</span><span style="color:#89DDFF;">&#39;</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&#39;</span><span style="color:#C3E88D;">--collect.info_schema.tables</span><span style="color:#89DDFF;">&#39;</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&#39;</span><span style="color:#C3E88D;">--collect.info_schema.userstats</span><span style="color:#89DDFF;">&#39;</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&#39;</span><span style="color:#C3E88D;">--collect.engine_innodb_status</span><span style="color:#89DDFF;">&#39;</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">environment</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">DATA_SOURCE_NAME=exporter:password@(192.168.88.101:3306)/</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">ports</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">9104:9104</span></span></code></pre></div><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#676E95;font-style:italic;"># 启动和检查</span></span>
<span class="line"><span style="color:#FFCB6B;">docker-compose</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">up</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-d</span></span>
<span class="line"><span style="color:#FFCB6B;">docker</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">ps</span></span>
<span class="line"><span style="color:#FFCB6B;">docker</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">exec</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-it</span><span style="color:#A6ACCD;">  </span><span style="color:#C3E88D;">mysql</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">mysql</span><span style="color:#A6ACCD;">  </span><span style="color:#C3E88D;">-uroot</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-h192.168.31.70</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-P3306</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-p</span></span></code></pre></div><p>访问：<a href="http://192.168.88.101:9104/metrics" target="_blank" rel="noreferrer">http://192.168.88.101:9104/metrics</a></p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304272131379.png" alt="image-20230427213153290" style="zoom:80%;"><h2 id="prometheus配置-1" tabindex="-1">Prometheus配置 <a class="header-anchor" href="#prometheus配置-1" aria-label="Permalink to &quot;Prometheus配置&quot;">​</a></h2><p>配置prometheus去采集（拉取）mysql_exporter的监控样本数据</p><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#82AAFF;">cd</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">/data/docker-prometheus</span></span>
<span class="line"></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 在scrape_configs(搜刮配置):下⾯增加如下配置：</span></span>
<span class="line"><span style="color:#FFCB6B;">cat</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&gt;&gt;</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">prometheus/prometheus.yml</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&lt;&lt;</span><span style="color:#A6ACCD;"> &quot;</span><span style="color:#89DDFF;">EOF</span><span style="color:#A6ACCD;">&quot;</span></span>
<span class="line"><span style="color:#C3E88D;">  - job_name: &#39;mysqld_exporter&#39;</span></span>
<span class="line"><span style="color:#C3E88D;">    static_configs:</span></span>
<span class="line"><span style="color:#C3E88D;">    - targets: [&#39;192.168.88.101:9104&#39;]</span></span>
<span class="line"><span style="color:#C3E88D;">      labels:</span></span>
<span class="line"><span style="color:#C3E88D;">        instance: test服务器</span></span>
<span class="line"><span style="color:#89DDFF;">EOF</span></span></code></pre></div><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#676E95;font-style:italic;"># 重新加载配置</span></span>
<span class="line"><span style="color:#FFCB6B;">curl</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-X</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">POST</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">:9090/-/reload</span></span></code></pre></div><h2 id="常用监控指标-1" tabindex="-1">常⽤监控指标 <a class="header-anchor" href="#常用监控指标-1" aria-label="Permalink to &quot;常⽤监控指标&quot;">​</a></h2><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#FFCB6B;">mysql_up</span><span style="color:#A6ACCD;"> </span><span style="color:#676E95;font-style:italic;"># 服务器是否在线</span></span>
<span class="line"><span style="color:#FFCB6B;">mysql_global_status_uptime</span><span style="color:#A6ACCD;"> </span><span style="color:#676E95;font-style:italic;"># 运⾏时⻓，单位 s</span></span>
<span class="line"><span style="color:#FFCB6B;">delta(mysql_global_status_bytes_received[1m]</span><span style="color:#A6ACCD;">) </span><span style="color:#676E95;font-style:italic;"># ⽹络接收的 bytes</span></span>
<span class="line"><span style="color:#FFCB6B;">delta(mysql_global_status_bytes_sent[1m]</span><span style="color:#A6ACCD;">) </span><span style="color:#676E95;font-style:italic;"># ⽹络发送的 bytes</span></span>
<span class="line"><span style="color:#FFCB6B;">mysql_global_status_threads_connected</span><span style="color:#A6ACCD;"> </span><span style="color:#676E95;font-style:italic;"># 当前的客户端连接数</span></span>
<span class="line"><span style="color:#FFCB6B;">mysql_global_variables_max_connections</span><span style="color:#A6ACCD;"> </span><span style="color:#676E95;font-style:italic;"># 允许的最⼤连接数</span></span>
<span class="line"><span style="color:#FFCB6B;">mysql_global_status_threads_running</span><span style="color:#A6ACCD;"> </span><span style="color:#676E95;font-style:italic;"># 正在执⾏命令的客户端连接数，即⾮ sleep 状态</span></span>
<span class="line"><span style="color:#FFCB6B;">delta(mysql_global_status_aborted_connects[1m]</span><span style="color:#A6ACCD;">) </span><span style="color:#676E95;font-style:italic;"># 客户端建⽴连接失败的连接数，⽐如登录失败</span></span>
<span class="line"><span style="color:#FFCB6B;">delta(mysql_global_status_aborted_clients[1m]</span><span style="color:#A6ACCD;">) </span><span style="color:#676E95;font-style:italic;"># 客户端连接之后，未正常关闭的连接数</span></span>
<span class="line"><span style="color:#FFCB6B;">delta(mysql_global_status_commands_total</span><span style="color:#A6ACCD;">{</span><span style="color:#82AAFF;">command</span><span style="color:#A6ACCD;">=</span><span style="color:#FFCB6B;">&quot;xx&quot;</span><span style="color:#FFCB6B;">}[1m]</span><span style="color:#A6ACCD;">) </span><span style="color:#89DDFF;">&gt;</span><span style="color:#A6ACCD;"> 0 </span><span style="color:#676E95;font-style:italic;"># 每分钟各种命令的次数</span></span>
<span class="line"><span style="color:#FFCB6B;">delta(mysql_global_status_handlers_total</span><span style="color:#A6ACCD;">{handler=</span><span style="color:#FFCB6B;">&quot;xx&quot;</span><span style="color:#FFCB6B;">}[1m]</span><span style="color:#A6ACCD;">) </span><span style="color:#89DDFF;">&gt;</span><span style="color:#A6ACCD;"> 0 </span><span style="color:#676E95;font-style:italic;"># 每分钟各种操作的次数</span></span>
<span class="line"><span style="color:#FFCB6B;">delta(mysql_global_status_handlers_total</span><span style="color:#A6ACCD;">{handler=</span><span style="color:#FFCB6B;">&quot;commit&quot;</span><span style="color:#FFCB6B;">}[1m]</span><span style="color:#A6ACCD;">) </span><span style="color:#89DDFF;">&gt;</span><span style="color:#A6ACCD;"> 0 </span><span style="color:#676E95;font-style:italic;"># 每分钟 commit 的次数</span></span>
<span class="line"><span style="color:#FFCB6B;">delta(mysql_global_status_table_locks_immediate[1m]</span><span style="color:#A6ACCD;">) </span><span style="color:#676E95;font-style:italic;"># 请求获取锁，且⽴即获得的请求数</span></span>
<span class="line"><span style="color:#FFCB6B;">delta(mysql_global_status_table_locks_waited[1m]</span><span style="color:#A6ACCD;">) </span><span style="color:#676E95;font-style:italic;"># 请求获取锁，但需要等待的请求数。该值越少越好</span></span>
<span class="line"><span style="color:#FFCB6B;">delta(mysql_global_status_queries[1m]</span><span style="color:#A6ACCD;">) </span><span style="color:#676E95;font-style:italic;"># 每分钟的查询数</span></span>
<span class="line"><span style="color:#FFCB6B;">delta(mysql_global_status_slow_queries[1m]</span><span style="color:#A6ACCD;">) </span><span style="color:#676E95;font-style:italic;"># 慢查询数。如果未启⽤慢查询⽇志，则为 0</span></span>
<span class="line"><span style="color:#FFCB6B;">mysql_global_status_innodb_page_size</span><span style="color:#A6ACCD;"> </span><span style="color:#676E95;font-style:italic;"># innodb 数据⻚的⼤⼩，单位 bytes</span></span>
<span class="line"><span style="color:#FFCB6B;">mysql_global_variables_innodb_buffer_pool_size</span><span style="color:#A6ACCD;"> </span><span style="color:#676E95;font-style:italic;"># innodb_buffer_pool 的限制体积</span></span>
<span class="line"><span style="color:#FFCB6B;">mysql_global_status_buffer_pool_pages</span><span style="color:#A6ACCD;">{state=</span><span style="color:#FFCB6B;">&quot;data&quot;</span><span style="color:#FFCB6B;">}</span><span style="color:#A6ACCD;"> </span><span style="color:#676E95;font-style:italic;"># 包含数据的数据⻚数，包括洁⻚、脏⻚</span></span>
<span class="line"><span style="color:#FFCB6B;">mysql_global_status_buffer_pool_dirty_pages</span><span style="color:#A6ACCD;"> </span><span style="color:#676E95;font-style:italic;"># 脏⻚数</span></span></code></pre></div><h2 id="触发器配置-1" tabindex="-1">触发器配置 <a class="header-anchor" href="#触发器配置-1" aria-label="Permalink to &quot;触发器配置&quot;">​</a></h2><div class="language-yml"><button title="Copy Code" class="copy"></button><span class="lang">yml</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#676E95;font-style:italic;"># 报警(触发器)配置</span></span>
<span class="line"><span style="color:#F07178;">rule_files</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">alert.yml</span><span style="color:#89DDFF;">&quot;</span><span style="color:#A6ACCD;"> </span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">rules/*.yml</span><span style="color:#89DDFF;">&quot;</span></span></code></pre></div><p>添加<strong>mysql</strong>触发器（告警规则）</p><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#82AAFF;">cd</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">/data/docker-prometheus</span></span></code></pre></div><p>使⽤cat创建⽂件</p><div class="language-yml"><button title="Copy Code" class="copy"></button><span class="lang">yml</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#F07178;">groups</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#F07178;">name</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">MySQL</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#F07178;">rules</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#F07178;">alert</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">MysqlDown</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">expr</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">mysql_up == 0</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">for</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">30s</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">labels</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">severity</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">critical</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">annotations</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">summary</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">MySQL Down,实例:{{ $labels.instance }}</span><span style="color:#89DDFF;">&quot;</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">description</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">MySQL_exporter连不上MySQL了，当前状态为：{{ $value }}</span><span style="color:#89DDFF;">&quot;</span><span style="color:#A6ACCD;"> </span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#F07178;">alert</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">MysqlTooManyConnections</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">expr</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">max_over_time(mysql_global_status_threads_connected[1m]) / mysql_global_variables_max_connections * 100 &gt; 80</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">for</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">2m</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">labels</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">severity</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">warning</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">annotations</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">summary</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">Mysql连接数过多告警,实例:{{ $labels.instance }}</span><span style="color:#89DDFF;">&quot;</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">description</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">MySQL连接数&gt;80%,当前值：{{ $value }}</span><span style="color:#89DDFF;">&quot;</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#F07178;">alert</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">MysqlHighThreadsRunning</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">expr</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">max_over_time(mysql_global_status_threads_running[1m]) &gt; 20</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">for</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">2m</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">labels</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">severity</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">warning</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">annotations</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">summary</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">Mysql运行的线程过多,实例:{{ $labels.instance }}</span><span style="color:#89DDFF;">&quot;</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">description</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">Mysql运行的线程 &gt; 20，当前运行的线程：{{ $value }}</span><span style="color:#89DDFF;">&quot;</span><span style="color:#A6ACCD;"> </span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#F07178;">alert</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">MysqlSlowQueries</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">expr</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">increase(mysql_global_status_slow_queries[2m]) &gt; 0</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">for</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">2m</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">labels</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">severity</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">warning</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">annotations</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">summary</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">Mysql慢日志告警,实例:{{ $labels.instance }}</span><span style="color:#89DDFF;">&quot;</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">description</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">MySQL在过去2分钟有新的{{ $value }}条慢查询</span><span style="color:#89DDFF;">&quot;</span></span>
<span class="line"><span style="color:#89DDFF;">  </span><span style="color:#676E95;font-style:italic;">#MySQL innodb 日志写入停滞</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#F07178;">alert</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">MysqlInnodbLogWaits</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">expr</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">rate(mysql_global_status_innodb_log_waits[15m]) &gt; 10</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">for</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">0m</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">labels</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">severity</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">warning</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">annotations</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">summary</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">MySQL innodb日志等待,实例:{{ $labels.instance }}</span><span style="color:#89DDFF;">&quot;</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">description</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">MySQL innodb日志写入停滞，当前值： {{ $value }}</span><span style="color:#89DDFF;">&quot;</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#F07178;">alert</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">MysqlRestarted</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">expr</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">mysql_global_status_uptime &lt; 60</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">for</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">0m</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">labels</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">severity</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">info</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">annotations</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">summary</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">MySQL 重启,实例:{{ $labels.instance }}</span><span style="color:#89DDFF;">&quot;</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">description</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">不到一分钟前，MySQL重启过</span><span style="color:#89DDFF;">&quot;</span></span></code></pre></div><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#FFCB6B;">./promtool</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">check</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">config</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">prometheus.yml</span></span>
<span class="line"><span style="color:#FFCB6B;">./promtool</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">check</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">rules</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">rules/linux.yml</span></span>
<span class="line"><span style="color:#FFCB6B;">curl</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-X</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">POST</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">:9090/-/reload</span></span></code></pre></div><h2 id="访问测试" tabindex="-1">访问测试 <a class="header-anchor" href="#访问测试" aria-label="Permalink to &quot;访问测试&quot;">​</a></h2><p>浏览器运行 <a href="http://192.168.88.101:9104/metrics%EF%BC%8C%E6%9F%A5%E7%9C%8B%E6%98%AF%E5%90%A6metrics%E6%95%B0%E6%8D%AE%E8%BE%93%E5%87%BA%EF%BC%8C%E5%A6%82%E6%9E%9C%E6%9C%89%E8%BE%93%E5%87%BA%E5%86%85%E5%AE%B9%E7%9B%91%E6%8E%A7%E5%B0%B1%E6%AD%A3%E5%B8%B8" target="_blank" rel="noreferrer">http://192.168.88.101:9104/metrics，查看是否metrics数据输出，如果有输出内容监控就正常</a></p><blockquote><p><a href="https://grafana.com/grafana/dashboards/7362" target="_blank" rel="noreferrer">https://grafana.com/grafana/dashboards/7362</a></p><p><a href="https://github.com/percona/grafana-dashboards/tree/main/dashboards/MySQL" target="_blank" rel="noreferrer">https://github.com/percona/grafana-dashboards/tree/main/dashboards/MySQL</a></p></blockquote><blockquote><p>导入7362即可，数据源就是Prometheus，导入成功后，就可以浏览Top Process States和 Process States图形修改为如下：mysql_info_schema_threads 替换成：mysql_info_schema_processlist_threads</p></blockquote><p>数据库表监控：<a href="https://grafana.com/grafana/dashboards/9625" target="_blank" rel="noreferrer">https://grafana.com/grafana/dashboards/9625</a></p><p>注意：2个图表没有数据，是因为只⽀持percona server 和 mariadb</p><blockquote><p>MySQL Uptime如果不显示，点击时间Last 5 Minutes即可,或者进入prometheus界面进行查询，来修改</p><p>mysql_global_status_uptime{instance=&quot;node1&quot;, job=&quot;mysqld_exporter&quot;}，或者刷新几次，等会就行</p></blockquote><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2022.8.30/202209091049454.png" alt="image-20220909104917327" style="zoom:80%;"><h1 id="nginx" tabindex="-1">Nginx <a class="header-anchor" href="#nginx" aria-label="Permalink to &quot;Nginx&quot;">​</a></h1><h2 id="前置准备" tabindex="-1">前置准备 <a class="header-anchor" href="#前置准备" aria-label="Permalink to &quot;前置准备&quot;">​</a></h2><p>nginx开启stub_status</p><p>注 监控nginx需要with-http_stub_status_module，检查是否安装有with-http_stub_status_module模块，默认安装</p><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#FFCB6B;">docker</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">exec</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-it</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">nginx</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">nginx</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-V</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">2&gt;&amp;1</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">|</span><span style="color:#A6ACCD;"> </span><span style="color:#FFCB6B;">grep</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-o</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">with-http_stub_status_module</span></span></code></pre></div><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304271551555.png" alt="image-20230427155106487" style="zoom:80%;"><p>nginx开启stub_status配置</p><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#82AAFF;">cd</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">/data/nginx/conf.d/</span></span>
<span class="line"><span style="color:#FFCB6B;">vim</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">server.conf</span></span></code></pre></div><blockquote><p>注意：只有server模块，没有http等模块</p></blockquote><div class="language-properties"><button title="Copy Code" class="copy"></button><span class="lang">properties</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#A6ACCD;">server {</span></span>
<span class="line"><span style="color:#A6ACCD;">    listen 80</span><span style="color:#676E95;font-style:italic;">;</span></span>
<span class="line"><span style="color:#A6ACCD;">    server_name localhost</span><span style="color:#676E95;font-style:italic;">;</span></span>
<span class="line"><span style="color:#A6ACCD;">    location /stub_status {</span></span>
<span class="line"><span style="color:#A6ACCD;">       stub_status on</span><span style="color:#676E95;font-style:italic;">;</span></span>
<span class="line"><span style="color:#A6ACCD;">       access_log off</span><span style="color:#676E95;font-style:italic;">;</span></span>
<span class="line"><span style="color:#89DDFF;">       </span><span style="color:#676E95;font-style:italic;">#allow nginx_export的ip; </span></span>
<span class="line"><span style="color:#A6ACCD;">       allow 0.0.0.0/0</span><span style="color:#676E95;font-style:italic;">;</span></span>
<span class="line"><span style="color:#A6ACCD;">       deny all</span><span style="color:#676E95;font-style:italic;">;</span></span>
<span class="line"><span style="color:#A6ACCD;">   }</span></span>
<span class="line"><span style="color:#A6ACCD;">    location / {</span></span>
<span class="line"><span style="color:#A6ACCD;">      root /usr/share/nginx/html</span><span style="color:#676E95;font-style:italic;">;</span></span>
<span class="line"><span style="color:#A6ACCD;">      index index.html</span><span style="color:#676E95;font-style:italic;">;</span></span>
<span class="line"><span style="color:#A6ACCD;">    }</span></span>
<span class="line"><span style="color:#A6ACCD;">}</span></span></code></pre></div><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#676E95;font-style:italic;"># 重新加载配置⽂件</span></span>
<span class="line"><span style="color:#FFCB6B;">docker</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">exec</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-it</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">nginx</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">nginx</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-t</span></span>
<span class="line"><span style="color:#FFCB6B;">docker</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">exec</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-it</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">nginx</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">nginx</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-s</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">reload</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 检查</span></span>
<span class="line"><span style="color:#FFCB6B;">curl</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">http://192.168.88.101/stub_status</span></span></code></pre></div><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304271557300.png" alt="image-20230427155753223" style="zoom:80%;"><h2 id="二进制安装-1" tabindex="-1">二进制安装 <a class="header-anchor" href="#二进制安装-1" aria-label="Permalink to &quot;二进制安装&quot;">​</a></h2><p>nginx_exporter下载地址: <a href="https://github.com/nginxinc/nginx-prometheus-exporter/releases" target="_blank" rel="noreferrer">https://github.com/nginxinc/nginx-prometheus-exporter/releases</a></p><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#676E95;font-style:italic;"># 下载⼆进制包解压并放⼊/opt⽬录</span></span>
<span class="line"><span style="color:#FFCB6B;">wget</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">https://github.com/nginxinc/nginx-prometheus-exporter/releases/download/v0.11.0/nginx-prometheus-exporter_0.11.0_linux_amd64.tar.gz</span></span>
<span class="line"><span style="color:#FFCB6B;">mkdir</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-p</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">/opt/module/nginx_exporter</span></span>
<span class="line"><span style="color:#FFCB6B;">tar</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-zxvf</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">nginx-prometheus-exporter_0.11.0_linux_amd64.tar.gz</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-C</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">/opt/module/nginx_exporter</span></span></code></pre></div><p>创建系统服务，nginx_exporter.service</p><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#FFCB6B;">cat</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&gt;</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">/etc/systemd/system/nginx_exporter.service</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&lt;&lt;</span><span style="color:#A6ACCD;">&quot;</span><span style="color:#89DDFF;">EOF</span><span style="color:#A6ACCD;">&quot;</span></span>
<span class="line"><span style="color:#C3E88D;">[Unit]</span></span>
<span class="line"><span style="color:#C3E88D;">Description=nginx-prometheus-exporter</span></span>
<span class="line"><span style="color:#C3E88D;">After=network.target</span></span>
<span class="line"><span style="color:#C3E88D;">[Service]</span></span>
<span class="line"><span style="color:#C3E88D;">Type=simple</span></span>
<span class="line"><span style="color:#C3E88D;">User=root</span></span>
<span class="line"><span style="color:#C3E88D;">Group=root</span></span>
<span class="line"><span style="color:#C3E88D;">Restart=always</span></span>
<span class="line"><span style="color:#C3E88D;">ExecStart=/opt/module/nginx_exporter/nginx-prometheus-exporter -nginx.scrape-uri=http://192.168.88.101/stub_status</span></span>
<span class="line"><span style="color:#C3E88D;">[Install]</span></span>
<span class="line"><span style="color:#C3E88D;">WantedBy=multi-user.target</span></span>
<span class="line"><span style="color:#89DDFF;">EOF</span></span></code></pre></div><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#676E95;font-style:italic;"># 启动 nginx_exporter</span></span>
<span class="line"><span style="color:#FFCB6B;">systemctl</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">daemon-reload</span></span>
<span class="line"><span style="color:#FFCB6B;">systemctl</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">start</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">nginx_exporter.service</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 加⼊到开机⾃启动</span></span>
<span class="line"><span style="color:#FFCB6B;">systemctl</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">enable</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">nginx_exporter.service</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 检查</span></span>
<span class="line"><span style="color:#FFCB6B;">systemctl</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">status</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">nginx_exporter.service</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 启动不了检查⽇志</span></span>
<span class="line"><span style="color:#FFCB6B;">journalctl</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-u</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">nginx_exporter.service</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-f</span></span></code></pre></div><h2 id="docker安装" tabindex="-1">Docker安装 <a class="header-anchor" href="#docker安装" aria-label="Permalink to &quot;Docker安装&quot;">​</a></h2><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#FFCB6B;">mkdir</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-p</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">/data/nginx/</span></span>
<span class="line"><span style="color:#82AAFF;">cd</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">/data/nginx/</span></span></code></pre></div><div class="language-yml"><button title="Copy Code" class="copy"></button><span class="lang">yml</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#C3E88D;">cat &gt;docker-compose.yaml &lt;&lt;EOF</span></span>
<span class="line"><span style="color:#F07178;">version</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&#39;</span><span style="color:#C3E88D;">3.3</span><span style="color:#89DDFF;">&#39;</span></span>
<span class="line"><span style="color:#F07178;">services</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#F07178;">nginx_exporter</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">image</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">nginx/nginx-prometheus-exporter:0.11</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">container_name</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">nginx_exporter</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">hostname</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">nginx_exporter</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">command</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&#39;</span><span style="color:#C3E88D;">-nginx.scrape-uri=http://192.168.88.101/stub_status</span><span style="color:#89DDFF;">&#39;</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">restart</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">always</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">ports</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">9113:9113</span><span style="color:#89DDFF;">&quot;</span></span>
<span class="line"><span style="color:#C3E88D;">EOF</span></span></code></pre></div><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#FFCB6B;">docker-compose</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">up</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-d</span></span>
<span class="line"><span style="color:#FFCB6B;">docker</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">ps</span></span>
<span class="line"><span style="color:#FFCB6B;">docker</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">logs</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-f</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">nginx_exporter</span></span></code></pre></div><h2 id="prometheus配置-2" tabindex="-1">Prometheus配置 <a class="header-anchor" href="#prometheus配置-2" aria-label="Permalink to &quot;Prometheus配置&quot;">​</a></h2><p>配置prometheus去采集（拉取）nginx_exporter的监控样本数据</p><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#676E95;font-style:italic;">#在scrape_configs(搜刮配置):下⾯增加如下配置：</span></span>
<span class="line"><span style="color:#FFCB6B;">cat</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&gt;&gt;</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">prometheus/prometheus.yml</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&lt;&lt;</span><span style="color:#A6ACCD;"> &quot;</span><span style="color:#89DDFF;">EOF</span><span style="color:#A6ACCD;">&quot;</span></span>
<span class="line"><span style="color:#C3E88D;">  - job_name: &#39;nginx_exporter&#39;</span></span>
<span class="line"><span style="color:#C3E88D;">    static_configs:</span></span>
<span class="line"><span style="color:#C3E88D;">    - targets: [&#39;192.168.88.101:9113&#39;]</span></span>
<span class="line"><span style="color:#C3E88D;">      labels:</span></span>
<span class="line"><span style="color:#C3E88D;">        instance: test服务器</span></span>
<span class="line"><span style="color:#89DDFF;">EOF</span></span></code></pre></div><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#676E95;font-style:italic;"># 重新加载配置</span></span>
<span class="line"><span style="color:#FFCB6B;">curl</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-X</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">POST</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">:9090/-/reload</span></span></code></pre></div><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304271043442.png" alt="image-20230427104302235" style="zoom:80%;"><h2 id="常用监控指标-2" tabindex="-1">常⽤监控指标 <a class="header-anchor" href="#常用监控指标-2" aria-label="Permalink to &quot;常⽤监控指标&quot;">​</a></h2><div class="language-"><button title="Copy Code" class="copy"></button><span class="lang"></span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#A6ACCD;">nginx_connections_accepted 接收请求数</span></span>
<span class="line"><span style="color:#A6ACCD;"></span></span>
<span class="line"><span style="color:#A6ACCD;">nginx_connections_active 活动连接数nginx_connections_handled 成功处理请求数</span></span>
<span class="line"><span style="color:#A6ACCD;"></span></span>
<span class="line"><span style="color:#A6ACCD;">nginx_connections_reding 正在进⾏读操作的请求数</span></span>
<span class="line"><span style="color:#A6ACCD;"></span></span>
<span class="line"><span style="color:#A6ACCD;">nginx_connections_waiting 正在等待的请求数</span></span>
<span class="line"><span style="color:#A6ACCD;"></span></span>
<span class="line"><span style="color:#A6ACCD;">nginx_connections_writing 正在进⾏写操作的请求数</span></span>
<span class="line"><span style="color:#A6ACCD;"></span></span>
<span class="line"><span style="color:#A6ACCD;">nginx_connections_requests 总请求数</span></span></code></pre></div><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304271043909.png" alt="image-20230427104355703" style="zoom:80%;"><h2 id="添加触发器" tabindex="-1">添加触发器 <a class="header-anchor" href="#添加触发器" aria-label="Permalink to &quot;添加触发器&quot;">​</a></h2><p>nginx.yml</p><div class="language-yml"><button title="Copy Code" class="copy"></button><span class="lang">yml</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#F07178;">groups</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#F07178;">name</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">Prometheus alert</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#F07178;">rules</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#F07178;">alert</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">NginxDown</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">expr</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">nginx_up == 0</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">for</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">30s</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">labels</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">severity</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">critical</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">annotations</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">summary</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">nginx异常,实例:{{ $labels.instance }}</span><span style="color:#89DDFF;">&quot;</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">description</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">{{ $labels.job }} nginx已关闭</span><span style="color:#89DDFF;">&quot;</span></span></code></pre></div><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#676E95;font-style:italic;"># 检查规则写的是否正确</span></span>
<span class="line"><span style="color:#FFCB6B;">./promtool</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">check</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">config</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">/etc/prometheus/prometheus.yml</span></span>
<span class="line"><span style="color:#FFCB6B;">./promtool</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">check</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">rules</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">rules/nginx.yml</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 热更新配置文件</span></span>
<span class="line"><span style="color:#FFCB6B;">curl</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-X</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">POST</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">http://node1:9090/-/reload</span></span>
<span class="line"></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 检查</span></span>
<span class="line"><span style="color:#FFCB6B;">http://192.168.11.61:9090/alerts?search</span><span style="color:#A6ACCD;">=</span></span>
<span class="line"><span style="color:#FFCB6B;">http://192.168.11.61:9090/rules</span></span></code></pre></div><h2 id="dashboard-1" tabindex="-1">dashboard <a class="header-anchor" href="#dashboard-1" aria-label="Permalink to &quot;dashboard&quot;">​</a></h2><p>grafana展示prometheus从nginx_exporter收集到的的数据</p><p><a href="https://grafana.com/grafana/dashboards/12708" target="_blank" rel="noreferrer">https://grafana.com/grafana/dashboards/12708</a></p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304271612008.png" alt="image-20230427161204878" style="zoom:80%;"><h1 id="redis" tabindex="-1">Redis <a class="header-anchor" href="#redis" aria-label="Permalink to &quot;Redis&quot;">​</a></h1><p>redis_exporter：<a href="https://github.com/oliver006/redis_exporter" target="_blank" rel="noreferrer">https://github.com/oliver006/redis_exporter</a></p><h2 id="安装访问" tabindex="-1">安装访问 <a class="header-anchor" href="#安装访问" aria-label="Permalink to &quot;安装访问&quot;">​</a></h2><h3 id="redis安装" tabindex="-1">Redis安装 <a class="header-anchor" href="#redis安装" aria-label="Permalink to &quot;Redis安装&quot;">​</a></h3><p>docker-compose.yaml</p><div class="language-yml"><button title="Copy Code" class="copy"></button><span class="lang">yml</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#F07178;">version</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&#39;</span><span style="color:#C3E88D;">3</span><span style="color:#89DDFF;">&#39;</span></span>
<span class="line"><span style="color:#F07178;">services</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#F07178;">redis</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">image</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">redis</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">container_name</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">redis</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">command</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">redis-server /usr/local/etc/redis/redis.conf</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">restart</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">always</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">volumes</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">/data/redis/data:/data</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">/data/redis/redis.conf:/usr/local/etc/redis/redis.conf</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">ports</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">6379:6379</span></span></code></pre></div><p>redis.conf</p><div class="language-properties"><button title="Copy Code" class="copy"></button><span class="lang">properties</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#676E95;font-style:italic;"># Redis 配置文件示例</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 绑定的 IP 地址，默认为本地回环地址 127.0.0.1</span></span>
<span class="line"><span style="color:#A6ACCD;">bind 0.0.0.0</span></span>
<span class="line"></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 监听的端口，默认为 6379</span></span>
<span class="line"><span style="color:#A6ACCD;">port 6379</span></span>
<span class="line"></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 设置密码，将密码修改为你想要的密码</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 如果不需要密码，可以注释掉或删除这一行</span></span>
<span class="line"><span style="color:#A6ACCD;">requirepass 123456</span></span>
<span class="line"></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 数据库文件存放的路径，默认为当前目录下的 `dump.rdb`</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 可以根据需要修改为其他路径和文件名</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># dbfilename dump.rdb</span></span>
<span class="line"></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 日志文件存放的路径，默认为标准输出</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 可以根据需要修改为其他路径和文件名</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># logfile &quot;&quot;</span></span>
<span class="line"></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 其他配置项可以根据需要进行修改和添加</span></span></code></pre></div><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#FFCB6B;">docker-compose</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">up</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-d</span></span>
<span class="line"><span style="color:#FFCB6B;">docker</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">ps</span></span></code></pre></div><h3 id="二进制安装-2" tabindex="-1">二进制安装 <a class="header-anchor" href="#二进制安装-2" aria-label="Permalink to &quot;二进制安装&quot;">​</a></h3><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#FFCB6B;">wget</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">https://github.com/oliver006/redis_exporter/releases/download/v1.48.0/redis_exporter-v1.48.0.linux-amd64.tar.gz</span></span>
<span class="line"><span style="color:#FFCB6B;">tar</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-xzvf</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">redis_exporter-v1.48.0.linux-amd64.tar.gz</span></span>
<span class="line"><span style="color:#FFCB6B;">mkdir</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">/opt/prometheus/</span></span>
<span class="line"><span style="color:#FFCB6B;">mv</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">redis_exporter-v1.48.0.linux-amd64</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">/opt/prometheus/redis_exporter</span></span></code></pre></div><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#676E95;font-style:italic;"># 创建用户并更改权限</span></span>
<span class="line"><span style="color:#FFCB6B;">useradd</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-M</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-s</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">/usr/sbin/nologin</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">prometheus</span></span>
<span class="line"><span style="color:#FFCB6B;">chown</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">prometheus:prometheus</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-R</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">/opt/prometheus</span></span></code></pre></div><p><strong>创建</strong> <strong>systemd</strong> <strong>服务</strong>：redis_exporter.service</p><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#FFCB6B;">cat</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&gt;</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">/etc/systemd/system/redis_exporter.service</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&lt;&lt;</span><span style="color:#A6ACCD;">&quot;</span><span style="color:#89DDFF;">EOF</span><span style="color:#A6ACCD;">&quot;</span></span>
<span class="line"><span style="color:#C3E88D;">[Unit]</span></span>
<span class="line"><span style="color:#C3E88D;">Description=Prometheus Redis Exporter</span></span>
<span class="line"><span style="color:#C3E88D;">After=network.target</span></span>
<span class="line"><span style="color:#C3E88D;">[Service]</span></span>
<span class="line"><span style="color:#C3E88D;">Type=simple</span></span>
<span class="line"><span style="color:#C3E88D;">User=prometheus</span></span>
<span class="line"><span style="color:#C3E88D;">Group=prometheus</span></span>
<span class="line"><span style="color:#C3E88D;">Restart=always</span></span>
<span class="line"><span style="color:#C3E88D;">ExecStart=/opt/prometheus/redis_exporter/redis_exporter \</span></span>
<span class="line"><span style="color:#C3E88D;">-redis.addr localhost:6379 \</span></span>
<span class="line"><span style="color:#C3E88D;">-redis.password 123456</span></span>
<span class="line"><span style="color:#C3E88D;">[Install]</span></span>
<span class="line"><span style="color:#C3E88D;">WantedBy=multi-user.target</span></span>
<span class="line"><span style="color:#89DDFF;">EOF</span></span></code></pre></div><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#FFCB6B;">systemctl</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">daemon-reload</span></span>
<span class="line"><span style="color:#FFCB6B;">systemctl</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">start</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">redis_exporter</span></span>
<span class="line"><span style="color:#FFCB6B;">systemctl</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">enable</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">redis_exporter</span></span>
<span class="line"><span style="color:#FFCB6B;">systemctl</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">status</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">nredis_exporter</span></span>
<span class="line"><span style="color:#FFCB6B;">journalctl</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-u</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">redis_exporter</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-f</span></span></code></pre></div><h3 id="docker安装-1" tabindex="-1">Docker安装 <a class="header-anchor" href="#docker安装-1" aria-label="Permalink to &quot;Docker安装&quot;">​</a></h3><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#676E95;font-style:italic;"># 如果reidis有密码，后面再跟上 --redis.password &#39;123456&#39;，这边不能设置成node1，不然会出错</span></span>
<span class="line"><span style="color:#FFCB6B;">docker</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">run</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-d</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">--name</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">redis_exporter</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-p</span><span style="color:#A6ACCD;"> </span><span style="color:#F78C6C;">9121</span><span style="color:#C3E88D;">:9121</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">oliver006/redis_exporter</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">--redis.addr=redis://172.17.0.1:6379</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">--redis.password</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&#39;</span><span style="color:#C3E88D;">123456</span><span style="color:#89DDFF;">&#39;</span></span></code></pre></div><h3 id="docker-compose安装" tabindex="-1">Docker-compose安装 <a class="header-anchor" href="#docker-compose安装" aria-label="Permalink to &quot;Docker-compose安装&quot;">​</a></h3><div class="language-yml"><button title="Copy Code" class="copy"></button><span class="lang">yml</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#C3E88D;">cat &gt;docker-compose.yaml &lt;&lt;EOF</span></span>
<span class="line"><span style="color:#F07178;">version</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&#39;</span><span style="color:#C3E88D;">3.3</span><span style="color:#89DDFF;">&#39;</span></span>
<span class="line"><span style="color:#F07178;">services</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#F07178;">redis_exporter</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">image</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">oliver006/redis_exporter</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">container_name</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">redis_exporter</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">restart</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">always</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">environment</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">REDIS_ADDR</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">192.168.88.101:6379</span><span style="color:#89DDFF;">&quot;</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">REDIS_PASSWORD</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#F78C6C;">123456</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">ports</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">9121:9121</span><span style="color:#89DDFF;">&quot;</span></span>
<span class="line"><span style="color:#C3E88D;">EOF</span></span></code></pre></div><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#FFCB6B;">docker-compose</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">up</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-d</span></span>
<span class="line"><span style="color:#FFCB6B;">docker</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">ps</span></span>
<span class="line"><span style="color:#FFCB6B;">docker</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">logs</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-f</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">redis_exporter</span></span></code></pre></div><p>访问测试：<a href="http://node1:9121/metrics" target="_blank" rel="noreferrer">http://node1:9121/metrics</a></p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304251553200.png" alt="image-20230425155321076" style="zoom:80%;"><blockquote><p>注意：此时如果redis_up=0说明没有监控到redis，则上面的命令有误，看下是不是连接和密码的问题</p></blockquote><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304251703385.png" alt="image-20230425170331284" style="zoom:80%;"><h2 id="配置prometheus" tabindex="-1">配置prometheus <a class="header-anchor" href="#配置prometheus" aria-label="Permalink to &quot;配置prometheus&quot;">​</a></h2><p>prometheus.yml</p><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#FFCB6B;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">job_name:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&#39;</span><span style="color:#C3E88D;">redis</span><span style="color:#89DDFF;">&#39;</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#FFCB6B;">static_configs:</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#FFCB6B;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">targets:</span><span style="color:#A6ACCD;"> [</span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">node1:9121</span><span style="color:#89DDFF;">&quot;</span><span style="color:#A6ACCD;">]</span></span></code></pre></div><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#676E95;font-style:italic;"># 热更新配置文件</span></span>
<span class="line"><span style="color:#FFCB6B;">curl</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-X</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">POST</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">http://node1:9090/-/reload</span></span></code></pre></div><p><a href="http://node1:9090/targets#pool-redis" target="_blank" rel="noreferrer">http://node1:9090/targets#pool-redis</a></p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304251604242.png" alt="image-20230425160409145" style="zoom:67%;"><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304251606934.png" alt="image-20230425160623830" style="zoom:80%;"><h2 id="常用监控指标-3" tabindex="-1">常用监控指标 <a class="header-anchor" href="#常用监控指标-3" aria-label="Permalink to &quot;常用监控指标&quot;">​</a></h2><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#FFCB6B;">redis_up</span><span style="color:#A6ACCD;"> </span><span style="color:#676E95;font-style:italic;"># 服务器是否在线</span></span>
<span class="line"><span style="color:#FFCB6B;">redis_uptime_in_seconds</span><span style="color:#A6ACCD;"> </span><span style="color:#676E95;font-style:italic;"># 运⾏时⻓，单位 s</span></span>
<span class="line"><span style="color:#FFCB6B;">rate(redis_cpu_sys_seconds_total[1m]</span><span style="color:#A6ACCD;">) + rate</span><span style="color:#89DDFF;">(</span><span style="color:#FFCB6B;">redis_cpu_user_seconds_total[1m]</span><span style="color:#89DDFF;">)</span><span style="color:#A6ACCD;"> </span><span style="color:#676E95;font-style:italic;"># CPU使用率</span></span>
<span class="line"><span style="color:#FFCB6B;">redis_memory_used_bytes</span><span style="color:#A6ACCD;"> </span><span style="color:#676E95;font-style:italic;"># 占⽤内存量</span></span>
<span class="line"><span style="color:#FFCB6B;">redis_memory_max_bytes</span><span style="color:#A6ACCD;"> </span><span style="color:#676E95;font-style:italic;"># 限制的最⼤内存，如果没限制则为 0</span></span>
<span class="line"><span style="color:#FFCB6B;">delta(redis_net_input_bytes_total[1m]</span><span style="color:#A6ACCD;">) </span><span style="color:#676E95;font-style:italic;"># ⽹络接收的 bytes</span></span>
<span class="line"><span style="color:#FFCB6B;">delta(redis_net_output_bytes_total[1m]</span><span style="color:#A6ACCD;">) </span><span style="color:#676E95;font-style:italic;"># ⽹络发送的 bytes</span></span>
<span class="line"><span style="color:#FFCB6B;">redis_connected_clients</span><span style="color:#A6ACCD;"> </span><span style="color:#676E95;font-style:italic;"># 客户端连接数</span></span>
<span class="line"><span style="color:#FFCB6B;">redis_connected_clients</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">/</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">redis_config_maxclients</span><span style="color:#A6ACCD;"> </span><span style="color:#676E95;font-style:italic;"># 连接数使⽤率</span></span>
<span class="line"><span style="color:#FFCB6B;">redis_rejected_connections_total</span><span style="color:#A6ACCD;"> </span><span style="color:#676E95;font-style:italic;"># 拒绝的客户端连接数</span></span>
<span class="line"><span style="color:#FFCB6B;">redis_connected_slaves</span><span style="color:#A6ACCD;"> </span><span style="color:#676E95;font-style:italic;"># slave 连接数</span></span></code></pre></div><blockquote><ul><li>Uptime：Redis从启动到当前运行的时间。</li><li>Clients: 当前连接到Redis服务器的客户端数，用于掌握连接情况，判断是否需要调整集群数量或者连接数。</li><li>Memory Usage：Redis节点的内存使用率，用于资源消耗评估。</li><li>Commands Executed/sec：每秒成功执行的命令数。</li><li>Hits/Misses Per Sec:每秒服务器中键命中/非命中的比率，这个值可以用来评估设计是否合理。</li><li>Network I/O:网络I/O流量情况，可以用于评估带宽压力。</li><li>Expiring vs Not-Expiring Keys：过期的Keys的数量和未过期的Keys数量</li></ul></blockquote><h2 id="配置告警规则" tabindex="-1">配置告警规则 <a class="header-anchor" href="#配置告警规则" aria-label="Permalink to &quot;配置告警规则&quot;">​</a></h2><blockquote><p>在prometheus文件夹下的rules文件夹，新建redis.yml，写入以下内容</p></blockquote><div class="language-yml"><button title="Copy Code" class="copy"></button><span class="lang">yml</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#F07178;">groups</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#F07178;">name</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">redis</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">rules</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#F07178;">alert</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">RedisDown</span></span>
<span class="line"><span style="color:#A6ACCD;">        </span><span style="color:#F07178;">expr</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">redis_up == 0</span></span>
<span class="line"><span style="color:#A6ACCD;">        </span><span style="color:#F07178;">for</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">0m</span></span>
<span class="line"><span style="color:#A6ACCD;">        </span><span style="color:#F07178;">labels</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">          </span><span style="color:#F07178;">severity</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">critical</span></span>
<span class="line"><span style="color:#A6ACCD;">        </span><span style="color:#F07178;">annotations</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">          </span><span style="color:#F07178;">summary</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&#39;</span><span style="color:#C3E88D;">Redis Down,实例:{{ $labels.instance }}</span><span style="color:#89DDFF;">&#39;</span></span>
<span class="line"><span style="color:#A6ACCD;">          </span><span style="color:#F07178;">description</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">Redis实例 is down</span><span style="color:#89DDFF;">&quot;</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#F07178;">alert</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">RedisMissingBackup</span></span>
<span class="line"><span style="color:#A6ACCD;">        </span><span style="color:#F07178;">expr</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">time() - redis_rdb_last_save_timestamp_seconds &gt; 60 * 60 * 24</span></span>
<span class="line"><span style="color:#A6ACCD;">        </span><span style="color:#F07178;">for</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">0m</span></span>
<span class="line"><span style="color:#A6ACCD;">        </span><span style="color:#F07178;">labels</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">          </span><span style="color:#F07178;">severity</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">critical</span></span>
<span class="line"><span style="color:#A6ACCD;">        </span><span style="color:#F07178;">annotations</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">          </span><span style="color:#F07178;">summary</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">Redis备份丢失,实例:{{ $labels.instance }}</span><span style="color:#89DDFF;">&quot;</span></span>
<span class="line"><span style="color:#A6ACCD;">          </span><span style="color:#F07178;">description</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">Redis 24⼩时未备份</span><span style="color:#89DDFF;">&quot;</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#F07178;">alert</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">RedisOutOfConfiguredMaxmemory</span></span>
<span class="line"><span style="color:#A6ACCD;">        </span><span style="color:#F07178;">expr</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">redis_memory_used_bytes / redis_memory_max_bytes * 100 &gt; 90</span></span>
<span class="line"><span style="color:#A6ACCD;">        </span><span style="color:#F07178;">for</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">2m</span></span>
<span class="line"><span style="color:#A6ACCD;">        </span><span style="color:#F07178;">labels</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">          </span><span style="color:#F07178;">severity</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">warning</span></span>
<span class="line"><span style="color:#A6ACCD;">        </span><span style="color:#F07178;">annotations</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">          </span><span style="color:#F07178;">summary</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">Redis超出配置的最大内存,实例:{{ $labels.instance }}</span><span style="color:#89DDFF;">&quot;</span></span>
<span class="line"><span style="color:#A6ACCD;">          </span><span style="color:#F07178;">description</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">Redis内存使用超过配置最大内存的90%</span><span style="color:#89DDFF;">&quot;</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#F07178;">alert</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">RedisTooManyConnections</span></span>
<span class="line"><span style="color:#A6ACCD;">        </span><span style="color:#F07178;">expr</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">redis_connected_clients &gt; 100</span></span>
<span class="line"><span style="color:#A6ACCD;">        </span><span style="color:#F07178;">for</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">2m</span></span>
<span class="line"><span style="color:#A6ACCD;">        </span><span style="color:#F07178;">labels</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">          </span><span style="color:#F07178;">severity</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">warning</span></span>
<span class="line"><span style="color:#A6ACCD;">        </span><span style="color:#F07178;">annotations</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">          </span><span style="color:#F07178;">summary</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">Redis连接数过多,实例:{{ $labels.instance }}</span><span style="color:#89DDFF;">&quot;</span></span>
<span class="line"><span style="color:#A6ACCD;">          </span><span style="color:#F07178;">description</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">Redis当前连接数为： {{ $value }}</span><span style="color:#89DDFF;">&quot;</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#F07178;">alert</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">RedisNotEnoughConnections</span></span>
<span class="line"><span style="color:#A6ACCD;">        </span><span style="color:#F07178;">expr</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">redis_connected_clients &lt; 1</span></span>
<span class="line"><span style="color:#A6ACCD;">        </span><span style="color:#F07178;">for</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">2m</span></span>
<span class="line"><span style="color:#A6ACCD;">        </span><span style="color:#F07178;">labels</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">          </span><span style="color:#F07178;">severity</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">warning</span></span>
<span class="line"><span style="color:#A6ACCD;">        </span><span style="color:#F07178;">annotations</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">          </span><span style="color:#F07178;">summary</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">Redis没有⾜够的连接,实例:{{ $labels.instance }}</span><span style="color:#89DDFF;">&quot;</span></span>
<span class="line"><span style="color:#A6ACCD;">          </span><span style="color:#F07178;">description</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">Redis当前连接数为： {{ $value }}</span><span style="color:#89DDFF;">&quot;</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#F07178;">alert</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">RedisRejectedConnections</span></span>
<span class="line"><span style="color:#A6ACCD;">        </span><span style="color:#F07178;">expr</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">increase(redis_rejected_connections_total[1m]) &gt; 0</span></span>
<span class="line"><span style="color:#A6ACCD;">        </span><span style="color:#F07178;">for</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">0m</span></span>
<span class="line"><span style="color:#A6ACCD;">        </span><span style="color:#F07178;">labels</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">          </span><span style="color:#F07178;">severity</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">critical</span></span>
<span class="line"><span style="color:#A6ACCD;">        </span><span style="color:#F07178;">annotations</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">          </span><span style="color:#F07178;">summary</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">Redis有拒绝连接,实例:{{ $labels.instance }}</span><span style="color:#89DDFF;">&quot;</span></span>
<span class="line"><span style="color:#A6ACCD;">          </span><span style="color:#F07178;">description</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">与Redis 的某些连接被拒绝{{ $value }}</span><span style="color:#89DDFF;">&quot;</span></span></code></pre></div><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#676E95;font-style:italic;"># 检查配置文件并热更新</span></span>
<span class="line"><span style="color:#FFCB6B;">./promtool</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">check</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">rules</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">rules/redis.yml</span></span>
<span class="line"><span style="color:#FFCB6B;">curl</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-X</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">POST</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">http://node1:9090/-/reload</span></span></code></pre></div><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304271632179.png" alt="image-20230427163205101" style="zoom:80%;"><h2 id="配置仪表盘" tabindex="-1">配置仪表盘 <a class="header-anchor" href="#配置仪表盘" aria-label="Permalink to &quot;配置仪表盘&quot;">​</a></h2><p><a href="https://grafana.com/grafana/dashboards/11835" target="_blank" rel="noreferrer">https://grafana.com/grafana/dashboards/11835</a></p><p><a href="https://grafana.com/grafana/dashboards/17507" target="_blank" rel="noreferrer">https://grafana.com/grafana/dashboards/17507</a></p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304251701764.png" alt="image-20230425170157644" style="zoom:80%;"><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304251631313.png" alt="image-20230425163122211" style="zoom:67%;"><p>修改Memory Usage显示无穷大的问题</p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304251700272.png" alt="image-20230425170022191" style="zoom:80%;"><blockquote><p>100 * (redis_memory_used_bytes{instance=~&quot;$instance&quot;} / 104857600)</p></blockquote><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304251701882.png" alt="image-20230425170104728" style="zoom:80%;"><blockquote><p><a href="https://grafana.com/grafana/dashboards/17507" target="_blank" rel="noreferrer">https://grafana.com/grafana/dashboards/17507</a></p><p>关于CPU使用率不显示的问题，修改如下，即可正常显示</p></blockquote><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#FFCB6B;">100</span><span style="color:#A6ACCD;"> </span><span style="color:#A6ACCD;">*</span><span style="color:#A6ACCD;"> (rate(redis_cpu_sys_seconds_total[1m]) + rate</span><span style="color:#89DDFF;">(</span><span style="color:#FFCB6B;">redis_cpu_user_seconds_total[1m]</span><span style="color:#89DDFF;">)</span><span style="color:#A6ACCD;">) / 60</span></span></code></pre></div><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304271654463.png" alt="image-20230427165402381" style="zoom:80%;"><h1 id="es" tabindex="-1">ES <a class="header-anchor" href="#es" aria-label="Permalink to &quot;ES&quot;">​</a></h1><p>官网：<a href="https://github.com/prometheus-community/elasticsearch_exporter" target="_blank" rel="noreferrer">https://github.com/prometheus-community/elasticsearch_exporter</a></p><h2 id="docker-compose配置" tabindex="-1">docker-compose配置 <a class="header-anchor" href="#docker-compose配置" aria-label="Permalink to &quot;docker-compose配置&quot;">​</a></h2><div class="language-yml"><button title="Copy Code" class="copy"></button><span class="lang">yml</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#F07178;">elasticsearch_exporter</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">image</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">quay.io/prometheuscommunity/elasticsearch-exporter:latest</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">command</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&#39;</span><span style="color:#C3E88D;">--es.uri=http://192.168.22.130:9200</span><span style="color:#89DDFF;">&#39;</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">restart</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">always</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">ports</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">9114:9114</span><span style="color:#89DDFF;">&quot;</span></span></code></pre></div><div class="language-apl"><button title="Copy Code" class="copy"></button><span class="lang">apl</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#A6ACCD;">docker</span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;">compose up </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;">d</span></span></code></pre></div><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2022.8.30/202209091826366.png" alt="image-20220909182640313" style="zoom:80%;"><p>访问：<a href="http://192.168.22.130:9114/metrics" target="_blank" rel="noreferrer">http://192.168.22.130:9114/metrics</a></p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2022.8.30/202209091825528.png" alt="image-20220909182522306" style="zoom:80%;"><p>修改：/mydata/prometheus/prometheus.yml</p><div class="language-yml"><button title="Copy Code" class="copy"></button><span class="lang">yml</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#F07178;">job_name</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">elasticsearch</span><span style="color:#89DDFF;">&quot;</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">static_configs</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#F07178;">targets</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">[</span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">192.168.22.130:9114</span><span style="color:#89DDFF;">&quot;</span><span style="color:#89DDFF;">]</span></span></code></pre></div><div class="language-apl"><button title="Copy Code" class="copy"></button><span class="lang">apl</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#A6ACCD;">docker restart prometheus</span></span></code></pre></div><p>访问：<a href="http://192.168.22.130:9090/targets" target="_blank" rel="noreferrer">http://192.168.22.130:9090/targets</a></p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2022.8.30/202209091829909.png" alt="image-20220909182958852" style="zoom:80%;"><h2 id="访问grafana测试" tabindex="-1">访问Grafana测试 <a class="header-anchor" href="#访问grafana测试" aria-label="Permalink to &quot;访问Grafana测试&quot;">​</a></h2><p>访问：<a href="http://192.168.22.130:3000/" target="_blank" rel="noreferrer">http://192.168.22.130:3000/</a></p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2022.8.30/202209091835304.png" alt="image-20220909183534237" style="zoom:80%;"><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2022.8.30/202209091834634.png" alt="image-20220909183450527" style="zoom:80%;"><h1 id="springboot" tabindex="-1">SpringBoot <a class="header-anchor" href="#springboot" aria-label="Permalink to &quot;SpringBoot&quot;">​</a></h1><blockquote><p>监控SpringBoot应用需要依靠<code>actuator</code>及<code>micrometer</code>，通过暴露<code>actuator</code>的端点，Prometheus可以定时获取并存储指标信息。</p></blockquote><h2 id="springboot配置" tabindex="-1">SpringBoot配置 <a class="header-anchor" href="#springboot配置" aria-label="Permalink to &quot;SpringBoot配置&quot;">​</a></h2><p>修改项目的<code>pom.xml</code>文件，添加<code>actuator</code>及<code>micrometer</code>依赖；</p><div class="language-xml"><button title="Copy Code" class="copy"></button><span class="lang">xml</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#89DDFF;">&lt;</span><span style="color:#F07178;">dependencies</span><span style="color:#89DDFF;">&gt;</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#676E95;font-style:italic;">&lt;!-- spring-boot-actuator依赖 --&gt;</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#89DDFF;">&lt;</span><span style="color:#F07178;">dependency</span><span style="color:#89DDFF;">&gt;</span></span>
<span class="line"><span style="color:#A6ACCD;">        </span><span style="color:#89DDFF;">&lt;</span><span style="color:#F07178;">groupId</span><span style="color:#89DDFF;">&gt;</span><span style="color:#A6ACCD;">org.springframework.boot</span><span style="color:#89DDFF;">&lt;/</span><span style="color:#F07178;">groupId</span><span style="color:#89DDFF;">&gt;</span></span>
<span class="line"><span style="color:#A6ACCD;">        </span><span style="color:#89DDFF;">&lt;</span><span style="color:#F07178;">artifactId</span><span style="color:#89DDFF;">&gt;</span><span style="color:#A6ACCD;">spring-boot-starter-actuator</span><span style="color:#89DDFF;">&lt;/</span><span style="color:#F07178;">artifactId</span><span style="color:#89DDFF;">&gt;</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#89DDFF;">&lt;/</span><span style="color:#F07178;">dependency</span><span style="color:#89DDFF;">&gt;</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#676E95;font-style:italic;">&lt;!-- prometheus依赖 --&gt;</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#89DDFF;">&lt;</span><span style="color:#F07178;">dependency</span><span style="color:#89DDFF;">&gt;</span></span>
<span class="line"><span style="color:#A6ACCD;">        </span><span style="color:#89DDFF;">&lt;</span><span style="color:#F07178;">groupId</span><span style="color:#89DDFF;">&gt;</span><span style="color:#A6ACCD;">io.micrometer</span><span style="color:#89DDFF;">&lt;/</span><span style="color:#F07178;">groupId</span><span style="color:#89DDFF;">&gt;</span></span>
<span class="line"><span style="color:#A6ACCD;">        </span><span style="color:#89DDFF;">&lt;</span><span style="color:#F07178;">artifactId</span><span style="color:#89DDFF;">&gt;</span><span style="color:#A6ACCD;">micrometer-registry-prometheus</span><span style="color:#89DDFF;">&lt;/</span><span style="color:#F07178;">artifactId</span><span style="color:#89DDFF;">&gt;</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#89DDFF;">&lt;/</span><span style="color:#F07178;">dependency</span><span style="color:#89DDFF;">&gt;</span></span>
<span class="line"><span style="color:#89DDFF;">&lt;/</span><span style="color:#F07178;">dependencies</span><span style="color:#89DDFF;">&gt;</span></span></code></pre></div><p>修改应用配置文件<code>application.yml</code>，通过<code>actuator</code>暴露监控端口<code>/actuator/prometheus</code>；</p><p>出于安全考虑，默认情况下除了/health和/info之外的所有actuator都是关闭的</p><div class="language-yml"><button title="Copy Code" class="copy"></button><span class="lang">yml</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#F07178;">management</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#F07178;">endpoints</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">web</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">exposure</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#89DDFF;">        </span><span style="color:#676E95;font-style:italic;"># 暴露端点`/actuator/prometheus`</span></span>
<span class="line"><span style="color:#A6ACCD;">        </span><span style="color:#F07178;">include</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">prometheus,health</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#F07178;">metrics</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">tags</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">application</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">${spring.application.name}</span></span></code></pre></div><p>在监控SpringBoot应用之前，我们需要先运行一个SpringBoot应用，使用如下命令运行即可；注意：可以直接在本地启动项目，上面连接写本机就行,</p><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#FFCB6B;">docker</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">run</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-d</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">--restart=always</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-p</span><span style="color:#A6ACCD;"> </span><span style="color:#F78C6C;">8081</span><span style="color:#C3E88D;">:8080</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">--name</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">springboot-demo</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">linge365/springboot-demo</span></span>
<span class="line"><span style="color:#FFCB6B;">http://192.168.11.62:8081/actuator/prometheus</span></span></code></pre></div><h2 id="prometheus配置-3" tabindex="-1">Prometheus配置 <a class="header-anchor" href="#prometheus配置-3" aria-label="Permalink to &quot;Prometheus配置&quot;">​</a></h2><p>prometheus配置采集springboot2.x的应⽤target提供的数据</p><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#82AAFF;">cd</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">/data/docker-prometheus</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 在scrape_configs(搜刮配置):下⾯增加如下配置：</span></span></code></pre></div><div class="language-yml"><button title="Copy Code" class="copy"></button><span class="lang">yml</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#C3E88D;">cat &gt;&gt; prometheus/prometheus.yml &lt;&lt; &quot;EOF&quot;</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># Spring Boot 2.x 应⽤数据采集配置</span></span>
<span class="line"><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#F07178;">job_name</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&#39;</span><span style="color:#C3E88D;">springboot-demo</span><span style="color:#89DDFF;">&#39;</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#F07178;">metrics_path</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&#39;</span><span style="color:#C3E88D;">/actuator/prometheus</span><span style="color:#89DDFF;">&#39;</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#F07178;">scrape_interval</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">5s</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#F07178;">static_configs</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#F07178;">targets</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">[</span><span style="color:#89DDFF;">&#39;</span><span style="color:#C3E88D;">192.168.11.62:8081</span><span style="color:#89DDFF;">&#39;</span><span style="color:#89DDFF;">]</span></span>
<span class="line"><span style="color:#C3E88D;">EOF</span></span></code></pre></div><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#FFCB6B;">curl</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-X</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">POST</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">:9090/-/reload</span></span>
<span class="line"><span style="color:#FFCB6B;">http://192.168.11.61:9090/targets?search</span><span style="color:#A6ACCD;">=</span></span></code></pre></div><h2 id="监控指标" tabindex="-1">监控指标 <a class="header-anchor" href="#监控指标" aria-label="Permalink to &quot;监控指标&quot;">​</a></h2><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#FFCB6B;">process_files_max_files</span><span style="color:#A6ACCD;"> </span><span style="color:#676E95;font-style:italic;"># 最⼤⽂件处理数量</span></span>
<span class="line"><span style="color:#FFCB6B;">tomcat_sessions_active_current_sessions</span><span style="color:#A6ACCD;"> </span><span style="color:#676E95;font-style:italic;"># Tomcat 当前活跃 session 数量</span></span>
<span class="line"><span style="color:#FFCB6B;">tomcat_sessions_alive_max_seconds</span><span style="color:#A6ACCD;"> </span><span style="color:#676E95;font-style:italic;"># Tomcat session 最⼤存活时间</span></span>
<span class="line"><span style="color:#FFCB6B;">jvm_buffer_total_capacity_bytes</span><span style="color:#A6ACCD;"> </span><span style="color:#676E95;font-style:italic;"># 预估的池中缓冲区的总容量</span></span>
<span class="line"><span style="color:#FFCB6B;">jvm_threads_daemon_threads</span><span style="color:#A6ACCD;"> </span><span style="color:#676E95;font-style:italic;"># 当前守护进程的线程数量</span></span>
<span class="line"><span style="color:#FFCB6B;">tomcat_global_request_max_seconds</span><span style="color:#A6ACCD;">{name=</span><span style="color:#FFCB6B;">&quot;http-nio-8080&quot;</span><span style="color:#FFCB6B;">,}</span><span style="color:#A6ACCD;"> </span><span style="color:#676E95;font-style:italic;"># 全局最⻓⼀次请求的时间</span></span>
<span class="line"><span style="color:#FFCB6B;">tomcat_sessions_active_max_sessions</span><span style="color:#A6ACCD;"> </span><span style="color:#676E95;font-style:italic;"># 最⼤活跃 session 数量</span></span>
<span class="line"><span style="color:#FFCB6B;">system_cpu_usage</span><span style="color:#A6ACCD;"> </span><span style="color:#676E95;font-style:italic;"># CPU 利⽤率</span></span>
<span class="line"><span style="color:#FFCB6B;">jvm_buffer_memory_used_bytes</span><span style="color:#A6ACCD;"> </span><span style="color:#676E95;font-style:italic;"># 预估 Java 虚拟机⽤于此缓冲池的内存</span></span>
<span class="line"><span style="color:#FFCB6B;">jvm_classes_loaded_classes</span><span style="color:#A6ACCD;"> </span><span style="color:#676E95;font-style:italic;"># 当前在 Java 虚拟机中加载的类的数量</span></span>
<span class="line"><span style="color:#FFCB6B;">jvm_memory_committed_bytes</span><span style="color:#A6ACCD;"> </span><span style="color:#676E95;font-style:italic;"># 为 Java 虚拟机提交的内存量（以字节为单位）</span></span>
<span class="line"><span style="color:#FFCB6B;">jvm_threads_live_threads</span><span style="color:#A6ACCD;"> </span><span style="color:#676E95;font-style:italic;"># 当前线程数，包括守护进程和⾮守护进程的线程</span></span>
<span class="line"><span style="color:#FFCB6B;">tomcat_threads_config_max_threads</span><span style="color:#A6ACCD;"> </span><span style="color:#676E95;font-style:italic;"># 配置的 Tomcat 的最⼤线程数</span></span>
<span class="line"><span style="color:#FFCB6B;">tomcat_global_received_bytes_total</span><span style="color:#A6ACCD;"> </span><span style="color:#676E95;font-style:italic;"># Tomcat 接收到的数据量</span></span>
<span class="line"><span style="color:#FFCB6B;">tomcat_global_sent_bytes_total</span><span style="color:#A6ACCD;"> </span><span style="color:#676E95;font-style:italic;"># Tomcat 发送的数据量</span></span>
<span class="line"><span style="color:#FFCB6B;">tomcat_threads_current_threads</span><span style="color:#A6ACCD;"> </span><span style="color:#676E95;font-style:italic;"># Tomcat 当前的线程数</span></span>
<span class="line"><span style="color:#FFCB6B;">tomcat_sessions_created_sessions_total</span><span style="color:#A6ACCD;"> </span><span style="color:#676E95;font-style:italic;"># Tomcat 创建的 session 数</span></span>
<span class="line"><span style="color:#FFCB6B;">system_load_average_1m</span><span style="color:#A6ACCD;"> </span><span style="color:#676E95;font-style:italic;"># 在⼀段时间内，排队到可⽤处理器的可运⾏实体数量和可⽤处理器上运⾏的可运⾏实体数量的总和的平均值</span></span>
<span class="line"><span style="color:#FFCB6B;">tomcat_sessions_expired_sessions_total</span><span style="color:#A6ACCD;"> </span><span style="color:#676E95;font-style:italic;"># 过期的 session 数量</span></span>
<span class="line"><span style="color:#FFCB6B;">jvm_buffer_count_buffers</span><span style="color:#A6ACCD;"> </span><span style="color:#676E95;font-style:italic;"># 预估的池中的缓冲区数量</span></span>
<span class="line"><span style="color:#FFCB6B;">jvm_memory_used_bytes#</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">JVM</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">内存使⽤量</span></span>
<span class="line"><span style="color:#FFCB6B;">process_uptime_seconds</span><span style="color:#A6ACCD;"> </span><span style="color:#676E95;font-style:italic;"># Java 虚拟机的正常运⾏时间</span></span>
<span class="line"><span style="color:#FFCB6B;">jvm_gc_memory_allocated_bytes_total</span><span style="color:#A6ACCD;"> </span><span style="color:#676E95;font-style:italic;"># 增加⼀个 GC 到下⼀个 GC 之后年轻代内存池的⼤⼩增加</span></span>
<span class="line"><span style="color:#FFCB6B;">jvm_gc_pause_seconds_count</span><span style="color:#A6ACCD;"> </span><span style="color:#676E95;font-style:italic;"># GC暂停耗时数量和总时间</span></span>
<span class="line"><span style="color:#FFCB6B;">jvm_gc_pause_seconds_sum</span></span>
<span class="line"><span style="color:#FFCB6B;">jvm_gc_pause_seconds_max</span></span>
<span class="line"><span style="color:#FFCB6B;">tomcat_sessions_rejected_sessions_total</span><span style="color:#A6ACCD;"> </span><span style="color:#676E95;font-style:italic;"># 被拒绝的 session 总数</span></span>
<span class="line"><span style="color:#FFCB6B;">jvm_gc_live_data_size_bytes#</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">Full</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">GC</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">后的⽼年代内存池的⼤⼩</span></span>
<span class="line"><span style="color:#FFCB6B;">tomcat_threads_busy_threads</span><span style="color:#A6ACCD;"> </span><span style="color:#676E95;font-style:italic;"># Tomcat 繁忙线程数</span></span>
<span class="line"><span style="color:#FFCB6B;">jvm_threads_peak_threads</span><span style="color:#A6ACCD;"> </span><span style="color:#676E95;font-style:italic;"># ⾃ Java 虚拟机启动或峰值重置以来的最⾼活动线程数</span></span>
<span class="line"><span style="color:#FFCB6B;">jvm_threads_states_threads</span><span style="color:#A6ACCD;"> </span><span style="color:#676E95;font-style:italic;"># 当前具有 NEW 状态的线程数</span></span>
<span class="line"><span style="color:#FFCB6B;">jvm_gc_max_data_size_bytes</span><span style="color:#A6ACCD;"> </span><span style="color:#676E95;font-style:italic;"># jvm_gc内存池的最⼤⼤⼩</span></span>
<span class="line"><span style="color:#FFCB6B;">http_server_requests_seconds_count</span><span style="color:#A6ACCD;"> </span><span style="color:#676E95;font-style:italic;">#某个接⼝的请求数量和请求总时间</span></span>
<span class="line"><span style="color:#FFCB6B;">http_server_requests_seconds_sum</span></span>
<span class="line"><span style="color:#FFCB6B;">http_server_requests_seconds_max</span></span>
<span class="line"><span style="color:#FFCB6B;">jvm_gc_memory_promoted_bytes_total</span><span style="color:#A6ACCD;"> </span><span style="color:#676E95;font-style:italic;"># GC之前到GC之后的⽼年代内存池⼤⼩的正增加计数</span></span>
<span class="line"></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># ⽇志按级别计数</span></span>
<span class="line"><span style="color:#FFCB6B;">logback_events_total</span><span style="color:#A6ACCD;">{application=</span><span style="color:#FFCB6B;">&quot;prometheus-demo&quot;</span><span style="color:#FFCB6B;">,level</span><span style="color:#A6ACCD;">=</span><span style="color:#FFCB6B;">&quot;info&quot;</span><span style="color:#FFCB6B;">,}</span><span style="color:#A6ACCD;"> </span><span style="color:#F78C6C;">7.0</span></span>
<span class="line"><span style="color:#FFCB6B;">logback_events_total</span><span style="color:#A6ACCD;">{application=</span><span style="color:#FFCB6B;">&quot;prometheus-demo&quot;</span><span style="color:#FFCB6B;">,level</span><span style="color:#A6ACCD;">=</span><span style="color:#FFCB6B;">&quot;trace&quot;</span><span style="color:#FFCB6B;">,}</span><span style="color:#A6ACCD;"> </span><span style="color:#F78C6C;">0.0</span></span>
<span class="line"><span style="color:#FFCB6B;">logback_events_total</span><span style="color:#A6ACCD;">{application=</span><span style="color:#FFCB6B;">&quot;prometheus-demo&quot;</span><span style="color:#FFCB6B;">,level</span><span style="color:#A6ACCD;">=</span><span style="color:#FFCB6B;">&quot;warn&quot;</span><span style="color:#FFCB6B;">,}</span><span style="color:#A6ACCD;"> </span><span style="color:#F78C6C;">0.0</span></span>
<span class="line"><span style="color:#FFCB6B;">logback_events_total</span><span style="color:#A6ACCD;">{application=</span><span style="color:#FFCB6B;">&quot;prometheus-demo&quot;</span><span style="color:#FFCB6B;">,level</span><span style="color:#A6ACCD;">=</span><span style="color:#FFCB6B;">&quot;debug&quot;</span><span style="color:#FFCB6B;">,}</span><span style="color:#A6ACCD;"> </span><span style="color:#F78C6C;">0.0</span></span>
<span class="line"><span style="color:#FFCB6B;">logback_events_total</span><span style="color:#A6ACCD;">{application=</span><span style="color:#FFCB6B;">&quot;prometheus-demo&quot;</span><span style="color:#FFCB6B;">,level</span><span style="color:#A6ACCD;">=</span><span style="color:#FFCB6B;">&quot;error&quot;</span><span style="color:#FFCB6B;">,}</span><span style="color:#A6ACCD;"> </span><span style="color:#F78C6C;">0.0</span></span>
<span class="line"></span>
<span class="line"><span style="color:#FFCB6B;">process_start_time_seconds</span><span style="color:#A6ACCD;"> </span><span style="color:#676E95;font-style:italic;"># 启动时间</span></span>
<span class="line"><span style="color:#FFCB6B;">process_files_open_files</span><span style="color:#A6ACCD;"> </span><span style="color:#676E95;font-style:italic;"># 打开⽂件描述符的数量</span></span>
<span class="line"><span style="color:#FFCB6B;">tomcat_global_error_total</span><span style="color:#A6ACCD;"> </span><span style="color:#676E95;font-style:italic;"># 异常数量</span></span>
<span class="line"><span style="color:#FFCB6B;">jvm_memory_max_bytes</span><span style="color:#A6ACCD;"> </span><span style="color:#676E95;font-style:italic;"># 可⽤于内存管理的最⼤内存量（以字节为单位）</span></span>
<span class="line"><span style="color:#FFCB6B;">process_cpu_usage</span><span style="color:#A6ACCD;"> </span><span style="color:#676E95;font-style:italic;"># 最近的 CPU 利⽤率</span></span>
<span class="line"><span style="color:#FFCB6B;">jvm_classes_unloaded_classes_total</span><span style="color:#A6ACCD;"> </span><span style="color:#676E95;font-style:italic;"># ⾃ Java 虚拟机开始执⾏以来卸载的类总数</span></span>
<span class="line"><span style="color:#FFCB6B;">system_cpu_count</span><span style="color:#A6ACCD;"> </span><span style="color:#676E95;font-style:italic;"># CPU 核数</span></span>
<span class="line"><span style="color:#FFCB6B;">tomcat_global_request_seconds_count</span><span style="color:#A6ACCD;"> </span><span style="color:#676E95;font-style:italic;"># 全局请求总数和总耗时</span></span>
<span class="line"><span style="color:#FFCB6B;">tomcat_global_request_seconds_sum</span></span></code></pre></div><h2 id="触发器" tabindex="-1">触发器 <a class="header-anchor" href="#触发器" aria-label="Permalink to &quot;触发器&quot;">​</a></h2><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#676E95;font-style:italic;"># 进⼊到prometheus安装⽬录</span></span>
<span class="line"><span style="color:#82AAFF;">cd</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">/data/docker-prometheus</span></span></code></pre></div><p>添加触发器（告警规则）</p><div class="language-yml"><button title="Copy Code" class="copy"></button><span class="lang">yml</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#C3E88D;">cat &gt;&gt; prometheus/rules/springboot.yml &lt;&lt;&quot;EOF&quot;</span></span>
<span class="line"><span style="color:#F07178;">groups</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#F07178;">name</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">SprinBoot</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">rules</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#F07178;">alert</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">SprinBooErrorEvents</span></span>
<span class="line"><span style="color:#A6ACCD;">        </span><span style="color:#F07178;">expr</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">increase(logback_events_total{level=&quot;error&quot;}[2m]) &gt; 0</span></span>
<span class="line"><span style="color:#A6ACCD;">        </span><span style="color:#F07178;">for</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">2m</span></span>
<span class="line"><span style="color:#A6ACCD;">        </span><span style="color:#F07178;">labels</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">          </span><span style="color:#F07178;">severity</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">warning</span></span>
<span class="line"><span style="color:#A6ACCD;">        </span><span style="color:#F07178;">annotations</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">          </span><span style="color:#F07178;">summary</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">Springboot错误事件 容器: $labels.instance</span><span style="color:#89DDFF;">&quot;</span></span>
<span class="line"><span style="color:#A6ACCD;">          </span><span style="color:#F07178;">description</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">在过去2分钟有新的{{ $value }}个错误事件</span><span style="color:#89DDFF;">&quot;</span></span>
<span class="line"><span style="color:#C3E88D;">EOF</span></span></code></pre></div><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#676E95;font-style:italic;"># 重新加载配置,检查</span></span>
<span class="line"><span style="color:#FFCB6B;">./promtool</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">check</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">rules</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">rules/spring.yml</span></span>
<span class="line"><span style="color:#FFCB6B;">curl</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-X</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">POST</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">http://node1:9090/-/reload</span></span>
<span class="line"></span>
<span class="line"><span style="color:#FFCB6B;">http://192.168.11.61:9090/alerts?search</span><span style="color:#A6ACCD;">=</span></span>
<span class="line"><span style="color:#FFCB6B;">http://192.168.11.61:9090/rules</span></span></code></pre></div><h2 id="dashboard-2" tabindex="-1">Dashboard <a class="header-anchor" href="#dashboard-2" aria-label="Permalink to &quot;Dashboard&quot;">​</a></h2><p>grafana将prometheus作为数据源进⾏可视化展示</p><h3 id="jvm监控" tabindex="-1">JVM监控 <a class="header-anchor" href="#jvm监控" aria-label="Permalink to &quot;JVM监控&quot;">​</a></h3><p><a href="https://grafana.com/grafana/dashboards/12856-jvm-micrometer/" target="_blank" rel="noreferrer">https://grafana.com/grafana/dashboards/12856-jvm-micrometer/</a></p><p><a href="https://grafana.com/grafana/dashboards/4701-jvm-micrometer/" target="_blank" rel="noreferrer">https://grafana.com/grafana/dashboards/4701-jvm-micrometer/</a></p><h3 id="应用监控⭐" tabindex="-1">应用监控⭐ <a class="header-anchor" href="#应用监控⭐" aria-label="Permalink to &quot;应用监控⭐&quot;">​</a></h3><p><a href="https://grafana.com/grafana/dashboards/10280" target="_blank" rel="noreferrer">https://grafana.com/grafana/dashboards/10280</a></p><p><a href="https://grafana.com/grafana/dashboards/14370" target="_blank" rel="noreferrer">https://grafana.com/grafana/dashboards/14370</a></p><h3 id="数据库连接池监控" tabindex="-1">数据库连接池监控 <a class="header-anchor" href="#数据库连接池监控" aria-label="Permalink to &quot;数据库连接池监控&quot;">​</a></h3><p>hikari连接池：<a href="https://grafana.com/grafana/dashboards/6083" target="_blank" rel="noreferrer">https://grafana.com/grafana/dashboards/6083</a></p><p>druid连接池：<a href="https://grafana.com/grafana/dashboards/11157" target="_blank" rel="noreferrer">https://grafana.com/grafana/dashboards/11157</a></p><p>导入成功后就可以在Grafana中看到SpringBoot实时监控信息了，果然够炫酷！</p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2022.5.13/202205181608186.png" alt="image-20220518160850123" style="zoom:80%;"><h1 id="rabbitmq" tabindex="-1">RabbitMQ <a class="header-anchor" href="#rabbitmq" aria-label="Permalink to &quot;RabbitMQ&quot;">​</a></h1><h2 id="二进制安装-3" tabindex="-1">二进制安装 <a class="header-anchor" href="#二进制安装-3" aria-label="Permalink to &quot;二进制安装&quot;">​</a></h2><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#FFCB6B;">wget</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">https://github.com/kbudde/rabbitmq_exporter/releases/download/v1.0.0-RC19/rabbitmq_exporter_1.0.0-RC19_linux_amd64.tar.gz</span></span>
<span class="line"><span style="color:#FFCB6B;">mkdir</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">/opt/prometheus/rabbitmq_exporter</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-p</span></span>
<span class="line"><span style="color:#FFCB6B;">tar</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-xzvf</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">rabbitmq_exporter_1.0.0-RC19_linux_amd64.tar.gz</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-C</span></span>
<span class="line"><span style="color:#FFCB6B;">/opt/prometheus/rabbitmq_exporter</span></span></code></pre></div><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#676E95;font-style:italic;"># 创建用户并更改exporter⽂件夹权限</span></span>
<span class="line"><span style="color:#FFCB6B;">useradd</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-M</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-s</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">/usr/sbin/nologin</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">prometheus</span></span>
<span class="line"><span style="color:#FFCB6B;">chown</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">prometheus:prometheus</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-R</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">/opt/prometheus</span></span></code></pre></div><p>创建 <strong>systemd</strong> 服务，使⽤cat创建</p><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#FFCB6B;">cat</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&gt;</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">/etc/systemd/system/rabbitmq_exporter.service</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&lt;&lt;</span><span style="color:#A6ACCD;">&quot;</span><span style="color:#89DDFF;">EOF</span><span style="color:#A6ACCD;">&quot;</span></span>
<span class="line"><span style="color:#C3E88D;">[Unit]</span></span>
<span class="line"><span style="color:#C3E88D;">Description=prometheus rabbitmq exporter</span></span>
<span class="line"><span style="color:#C3E88D;">After=network.target</span></span>
<span class="line"><span style="color:#C3E88D;">[Service]</span></span>
<span class="line"><span style="color:#C3E88D;">Environment=RABBIT_USER=guest</span></span>
<span class="line"><span style="color:#C3E88D;">Environment=RABBIT_PASSWORD=guest</span></span>
<span class="line"><span style="color:#C3E88D;">Environment=RABBIT_URL=:15672</span></span>
<span class="line"><span style="color:#C3E88D;">OUTPUT_FORMAT=JSON</span></span>
<span class="line"><span style="color:#C3E88D;">Type=simple</span></span>
<span class="line"><span style="color:#C3E88D;">User=prometheus</span></span>
<span class="line"><span style="color:#C3E88D;">Group=prometheus</span></span>
<span class="line"><span style="color:#C3E88D;">Restart=always</span></span>
<span class="line"><span style="color:#C3E88D;">ExecStart=/opt/prometheus/rabbitmq_exporter/rabbitmq_exporter</span></span>
<span class="line"><span style="color:#C3E88D;">[Install]</span></span>
<span class="line"><span style="color:#C3E88D;">WantedBy=multi-user.target</span></span>
<span class="line"><span style="color:#89DDFF;">EOF</span></span></code></pre></div><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#FFCB6B;">systemctl</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">daemon-reload</span></span>
<span class="line"><span style="color:#FFCB6B;">systemctl</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">start</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">rabbitmq_exporter</span></span>
<span class="line"><span style="color:#FFCB6B;">systemctl</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">enable</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">rabbitmq_exporter</span></span>
<span class="line"><span style="color:#FFCB6B;">systemctl</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">status</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">rabbitmq_exporter</span></span>
<span class="line"><span style="color:#FFCB6B;">journalctl</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-u</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">rabbitmq_exporter.service</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-f</span></span></code></pre></div><h2 id="docker安装-2" tabindex="-1">Docker安装 <a class="header-anchor" href="#docker安装-2" aria-label="Permalink to &quot;Docker安装&quot;">​</a></h2><blockquote><p>方式一：直接Docker安装</p></blockquote><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#FFCB6B;">docker</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">run</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-d</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">--restart=always</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-p</span><span style="color:#A6ACCD;"> </span><span style="color:#F78C6C;">9419</span><span style="color:#C3E88D;">:9419</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">--name</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">rabbitmq_exporter</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-e</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">RABBIT_URL=http://192.168.88.101:15672</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-e</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">RABBIT_USER=guest</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-e</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">RABBIT_PASSWORD=guest</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">kbudde/rabbitmq-exporter</span></span></code></pre></div><blockquote><p>方式二：Docker-compose安装</p></blockquote><div class="language-yml"><button title="Copy Code" class="copy"></button><span class="lang">yml</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#F07178;">version</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&#39;</span><span style="color:#C3E88D;">3.3</span><span style="color:#89DDFF;">&#39;</span></span>
<span class="line"><span style="color:#F07178;">services</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#F07178;">rabbitmq_exporter</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">image</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">kbudde/rabbitmq-exporter</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">container_name</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">rabbitmq_exporter</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">restart</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">always</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">environment</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">RABBIT_URL</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">http://192.168.11.62:15672</span><span style="color:#89DDFF;">&quot;</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">RABBIT_USER</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">guest</span><span style="color:#89DDFF;">&quot;</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">RABBIT_PASSWORD</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">guest</span><span style="color:#89DDFF;">&quot;</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">PUBLISH_PORT</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">9419</span><span style="color:#89DDFF;">&quot;</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">OUTPUT_FORMAT</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">JSON</span><span style="color:#89DDFF;">&quot;</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">ports</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">        </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">9419:9419</span><span style="color:#89DDFF;">&quot;</span></span></code></pre></div><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#FFCB6B;">docker</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">ps</span></span>
<span class="line"><span style="color:#FFCB6B;">docker</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">logs</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-f</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">rabbitmq_exporter</span></span></code></pre></div><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304271658779.png" alt="image-20230427165855704" style="zoom:80%;"><h2 id="prometheus配置-4" tabindex="-1">Prometheus配置 <a class="header-anchor" href="#prometheus配置-4" aria-label="Permalink to &quot;Prometheus配置&quot;">​</a></h2><p>prometheus.yml配置</p><div class="language-yml"><button title="Copy Code" class="copy"></button><span class="lang">yml</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#F07178;">job_name</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&#39;</span><span style="color:#C3E88D;">rabbitmq_exporter</span><span style="color:#89DDFF;">&#39;</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">static_configs</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#F07178;">targets</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">[</span><span style="color:#89DDFF;">&#39;</span><span style="color:#C3E88D;">192.168.88.101:9419</span><span style="color:#89DDFF;">&#39;</span><span style="color:#89DDFF;">]</span></span>
<span class="line"><span style="color:#A6ACCD;">        </span><span style="color:#F07178;">labels</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">          </span><span style="color:#F07178;">instance</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">test服务器</span></span></code></pre></div><div class="language-"><button title="Copy Code" class="copy"></button><span class="lang"></span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#A6ACCD;">curl -X POST :9090/-/reload</span></span></code></pre></div><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304271701589.png" alt="image-20230427170143519" style="zoom:80%;"><h2 id="常用监控指标-4" tabindex="-1">常用监控指标 <a class="header-anchor" href="#常用监控指标-4" aria-label="Permalink to &quot;常用监控指标&quot;">​</a></h2><blockquote><p>rabbitmq_queue_messages_unacknowledged_global 队列中有未确认的消息总数（未被消费的消息）</p><p>rabbitmq*_node_disk_free_limit* 使⽤磁盘⼤⼩</p><p>*rabbitmq_node_disk_*free 磁盘总⼤⼩</p><p>rabbitmq*_node_mem_used* <em>使⽤内存⼤⼩</em></p><p>*rabbitmq_node_mem_*limit 内存总⼤⼩</p><p>rabbitmq*_sockets_used* <em>使⽤<strong>sockets</strong>的数量</em></p><p>*rabbitmq_sockets_*available 可⽤的sockets总数</p><p>rabbitmq*_fd_used* 使⽤⽂件描述符的数量</p><p>*rabbitmq_fd_*available 可⽤的⽂件描述符总数</p></blockquote><h2 id="触发器配置-2" tabindex="-1">触发器配置 <a class="header-anchor" href="#触发器配置-2" aria-label="Permalink to &quot;触发器配置&quot;">​</a></h2><p>Prometheus配置</p><div class="language-yml"><button title="Copy Code" class="copy"></button><span class="lang">yml</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#676E95;font-style:italic;"># 报警(触发器)配置</span></span>
<span class="line"><span style="color:#F07178;">rule_files</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">alert.yml</span><span style="color:#89DDFF;">&quot;</span><span style="color:#A6ACCD;"> </span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">rules/*.yml</span><span style="color:#89DDFF;">&quot;</span></span></code></pre></div><div class="language-yml"><button title="Copy Code" class="copy"></button><span class="lang">yml</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#F07178;">groups</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#F07178;">name</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">Rabbitmq</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">rules</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#F07178;">alert</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">RabbitMQDown</span></span>
<span class="line"><span style="color:#A6ACCD;">        </span><span style="color:#F07178;">expr</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">rabbitmq_up != 1</span></span>
<span class="line"><span style="color:#A6ACCD;">        </span><span style="color:#F07178;">labels</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">          </span><span style="color:#F07178;">severity</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">High</span></span>
<span class="line"><span style="color:#A6ACCD;">        </span><span style="color:#F07178;">annotations</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">          </span><span style="color:#F07178;">summary</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">Rabbitmq Down,实例:{{ $labels.instance }}</span><span style="color:#89DDFF;">&quot;</span></span>
<span class="line"><span style="color:#A6ACCD;">          </span><span style="color:#F07178;">description</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">Rabbitmq_exporter连不上RabbitMQ! ! !</span><span style="color:#89DDFF;">&quot;</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#F07178;">alert</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">RabbitMQ有未确认消息</span></span>
<span class="line"><span style="color:#A6ACCD;">        </span><span style="color:#F07178;">expr</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">rabbitmq_queue_messages_unacknowledged_global &gt; 0</span></span>
<span class="line"><span style="color:#A6ACCD;">        </span><span style="color:#F07178;">for</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">1m</span></span>
<span class="line"><span style="color:#A6ACCD;">        </span><span style="color:#F07178;">labels</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">          </span><span style="color:#F07178;">severity</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">critical</span></span>
<span class="line"><span style="color:#A6ACCD;">        </span><span style="color:#F07178;">annotations</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">          </span><span style="color:#F07178;">summary</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">RabbitMQ有未确认消息,实例:{{ $labels.instance }}</span><span style="color:#89DDFF;">&quot;</span></span>
<span class="line"><span style="color:#A6ACCD;">          </span><span style="color:#F07178;">description</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&#39;</span><span style="color:#C3E88D;">RabbitMQ未确认消息&gt;0,当前值为：{{ $value }}</span><span style="color:#89DDFF;">&#39;</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#F07178;">alert</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">RabbitMQ可⽤磁盘空间不⾜告警</span></span>
<span class="line"><span style="color:#A6ACCD;">        </span><span style="color:#F07178;">expr</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">rabbitmq_node_disk_free_alarm != 0</span></span>
<span class="line"><span style="color:#A6ACCD;">        </span><span style="color:#F07178;">for</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">0m</span></span>
<span class="line"><span style="color:#A6ACCD;">        </span><span style="color:#F07178;">labels</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">          </span><span style="color:#F07178;">severity</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">critical</span></span>
<span class="line"><span style="color:#A6ACCD;">        </span><span style="color:#F07178;">annotations</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">          </span><span style="color:#F07178;">summary</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">RabbitMQ可⽤磁盘空间不⾜,实例:{{ $labels.instance }}</span><span style="color:#89DDFF;">&quot;</span></span>
<span class="line"><span style="color:#A6ACCD;">          </span><span style="color:#F07178;">description</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">RabbitMQ可⽤磁盘空间不⾜，请检查</span><span style="color:#89DDFF;">&quot;</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#F07178;">alert</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">RabbitMQ可⽤内存不⾜告警</span></span>
<span class="line"><span style="color:#A6ACCD;">        </span><span style="color:#F07178;">expr</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">rabbitmq_node_mem_alarm != 0</span></span>
<span class="line"><span style="color:#A6ACCD;">        </span><span style="color:#F07178;">for</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">0m</span></span>
<span class="line"><span style="color:#A6ACCD;">        </span><span style="color:#F07178;">labels</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">          </span><span style="color:#F07178;">severity</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">critical</span></span>
<span class="line"><span style="color:#A6ACCD;">        </span><span style="color:#F07178;">annotations</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">          </span><span style="color:#F07178;">summary</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">RabbitMQ可⽤内存不⾜,实例:{{ $labels.instance }}</span><span style="color:#89DDFF;">&quot;</span></span>
<span class="line"><span style="color:#A6ACCD;">          </span><span style="color:#F07178;">description</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">RabbitMQ可⽤内存不⾜，请检查</span><span style="color:#89DDFF;">&quot;</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#F07178;">alert</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">RabbitMQ_socket连接数使⽤过⾼告警</span></span>
<span class="line"><span style="color:#A6ACCD;">        </span><span style="color:#F07178;">expr</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">rabbitmq_sockets_used / rabbitmq_sockets_available * 100 &gt; 60</span></span>
<span class="line"><span style="color:#A6ACCD;">        </span><span style="color:#F07178;">for</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">0m</span></span>
<span class="line"><span style="color:#A6ACCD;">        </span><span style="color:#F07178;">labels</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">          </span><span style="color:#F07178;">severity</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">critical</span></span>
<span class="line"><span style="color:#A6ACCD;">        </span><span style="color:#F07178;">annotations</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">          </span><span style="color:#F07178;">summary</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">RabbitMQ_socket连接数使⽤过⾼,实例:{{ $labels.instance }}</span><span style="color:#89DDFF;">&quot;</span></span>
<span class="line"><span style="color:#A6ACCD;">          </span><span style="color:#F07178;">description</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&#39;</span><span style="color:#C3E88D;">RabbitMQ_sockets使⽤&gt;60%,当前值为：{{ $value }}</span><span style="color:#89DDFF;">&#39;</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#F07178;">alert</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">RabbitMQ⽂件描述符使⽤过⾼告警</span></span>
<span class="line"><span style="color:#A6ACCD;">        </span><span style="color:#F07178;">expr</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">rabbitmq_fd_used / rabbitmq_fd_available * 100 &gt; 60</span></span>
<span class="line"><span style="color:#A6ACCD;">        </span><span style="color:#F07178;">for</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">0m</span></span>
<span class="line"><span style="color:#A6ACCD;">        </span><span style="color:#F07178;">labels</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">          </span><span style="color:#F07178;">severity</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">critical</span></span>
<span class="line"><span style="color:#A6ACCD;">        </span><span style="color:#F07178;">annotations</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">          </span><span style="color:#F07178;">summary</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">RabbitMQ⽂件描述符使⽤过⾼,实例:{{ $labels.instance }}</span><span style="color:#89DDFF;">&quot;</span></span>
<span class="line"><span style="color:#A6ACCD;">          </span><span style="color:#F07178;">description</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&#39;</span><span style="color:#C3E88D;">RabbitMQ⽂件描述符使⽤&gt;60%,当前值为：{{ $value }}</span><span style="color:#89DDFF;">&#39;</span></span></code></pre></div><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#FFCB6B;">./promtool</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">check</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">rules</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">rules/nginx.yml</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 热更新配置文件</span></span>
<span class="line"><span style="color:#FFCB6B;">curl</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-X</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">POST</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">http://node1:9090/-/reload</span></span></code></pre></div><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304271706657.png" alt="image-20230427170652584" style="zoom:80%;"><h2 id="dashboard-3" tabindex="-1">dashboard <a class="header-anchor" href="#dashboard-3" aria-label="Permalink to &quot;dashboard&quot;">​</a></h2><p>grafana展示prometheus从rabbitmq_exporter收集到的的数据</p><p><a href="https://grafana.com/grafana/dashboards/4279-rabbitmq-monitoring/" target="_blank" rel="noreferrer">https://grafana.com/grafana/dashboards/4279-rabbitmq-monitoring/</a></p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304271711636.png" alt="image-20230427171125457" style="zoom:80%;"><h1 id="mongodb" tabindex="-1">mongodb <a class="header-anchor" href="#mongodb" aria-label="Permalink to &quot;mongodb&quot;">​</a></h1><h2 id="创建监控用户" tabindex="-1">创建监控⽤户 <a class="header-anchor" href="#创建监控用户" aria-label="Permalink to &quot;创建监控⽤户&quot;">​</a></h2><p>登陆mongodb创建监控⽤户，权限为“readAnyDatabase”，如果是cluster环境，需要有权限“clusterMonitor”</p><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#676E95;font-style:italic;"># 登录mongodb（docker安装的mongo）</span></span>
<span class="line"><span style="color:#FFCB6B;">docker</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">exec</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-it</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">mongo</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">mongo</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">admin</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 登录mongodb（yum和apt安装的mongo）</span></span>
<span class="line"><span style="color:#FFCB6B;">mongo</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">admin</span></span></code></pre></div><div class="language-sql"><button title="Copy Code" class="copy"></button><span class="lang">sql</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#A6ACCD;"># 登录root用户</span></span>
<span class="line"><span style="color:#A6ACCD;">db.auth(</span><span style="color:#89DDFF;">&#39;</span><span style="color:#C3E88D;">root</span><span style="color:#89DDFF;">&#39;</span><span style="color:#A6ACCD;">,</span><span style="color:#89DDFF;">&#39;</span><span style="color:#C3E88D;">123456</span><span style="color:#89DDFF;">&#39;</span><span style="color:#A6ACCD;">)</span></span>
<span class="line"><span style="color:#A6ACCD;"># 创建监控⽤户</span></span>
<span class="line"><span style="color:#A6ACCD;">db.createUser({ </span></span>
<span class="line"><span style="color:#A6ACCD;">              user:</span><span style="color:#89DDFF;">&#39;</span><span style="color:#C3E88D;">exporter</span><span style="color:#89DDFF;">&#39;</span><span style="color:#A6ACCD;">,</span></span>
<span class="line"><span style="color:#A6ACCD;">              pwd:</span><span style="color:#89DDFF;">&#39;</span><span style="color:#C3E88D;">password</span><span style="color:#89DDFF;">&#39;</span><span style="color:#A6ACCD;">,</span></span>
<span class="line"><span style="color:#A6ACCD;">              roles:[ </span></span>
<span class="line"><span style="color:#A6ACCD;">                  { </span></span>
<span class="line"><span style="color:#A6ACCD;">                     </span><span style="color:#F78C6C;">role</span><span style="color:#A6ACCD;">:</span><span style="color:#89DDFF;">&#39;</span><span style="color:#C3E88D;">readAnyDatabase</span><span style="color:#89DDFF;">&#39;</span><span style="color:#A6ACCD;">, </span></span>
<span class="line"><span style="color:#A6ACCD;">                     db:</span><span style="color:#89DDFF;">&#39;</span><span style="color:#C3E88D;">admin</span><span style="color:#89DDFF;">&#39;</span></span>
<span class="line"><span style="color:#A6ACCD;">                  },</span></span>
<span class="line"><span style="color:#A6ACCD;">                  {</span></span>
<span class="line"><span style="color:#A6ACCD;">                  </span><span style="color:#F78C6C;">role</span><span style="color:#A6ACCD;">: </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">clusterMonitor</span><span style="color:#89DDFF;">&quot;</span><span style="color:#A6ACCD;">, </span></span>
<span class="line"><span style="color:#A6ACCD;">                  db: </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">admin</span><span style="color:#89DDFF;">&quot;</span><span style="color:#A6ACCD;"> </span></span>
<span class="line"><span style="color:#A6ACCD;">                  }</span></span>
<span class="line"><span style="color:#A6ACCD;">              ]</span></span>
<span class="line"><span style="color:#A6ACCD;">      }</span></span>
<span class="line"><span style="color:#A6ACCD;">);</span></span></code></pre></div><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#676E95;font-style:italic;"># 测试 使⽤上⾯创建的⽤户信息进⾏连接</span></span>
<span class="line"><span style="color:#FFCB6B;">db.auth(</span><span style="color:#FFCB6B;">&#39;exporter&#39;</span><span style="color:#FFCB6B;">,</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&#39;</span><span style="color:#C3E88D;">password</span><span style="color:#89DDFF;">&#39;</span><span style="color:#A6ACCD;">)</span></span>
<span class="line"><span style="color:#82AAFF;">exit</span></span></code></pre></div><h2 id="mongodb-exporter" tabindex="-1">mongodb_exporter <a class="header-anchor" href="#mongodb-exporter" aria-label="Permalink to &quot;mongodb_exporter&quot;">​</a></h2><p>地址:<a href="https://github.com/percona/mongodb_exporter/releases" target="_blank" rel="noreferrer">https://github.com/percona/mongodb_exporter/releases</a></p><p>或：<a href="https://github.com/prometheus/mysqld_exporter/releases" target="_blank" rel="noreferrer">https://github.com/prometheus/mysqld_exporter/releases</a></p><h3 id="二进制安装-4" tabindex="-1">二进制安装 <a class="header-anchor" href="#二进制安装-4" aria-label="Permalink to &quot;二进制安装&quot;">​</a></h3><p>下载⼆进制包解压并放⼊**/opt**⽬录</p><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#FFCB6B;">wget</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">https://github.com/percona/mongodb_exporter/releases/download/v0.37.0/mongodb_exporter-0.37.0.linux-amd64.tar.gz</span></span>
<span class="line"><span style="color:#FFCB6B;">tar</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-xzvf</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">mongodb_exporter-0.37.0.linux-amd64.tar.gz</span></span>
<span class="line"><span style="color:#FFCB6B;">mv</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">mongodb_exporter-0.37.0.linux-amd64</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">mongodb_exporter</span></span></code></pre></div><p>创建systemd服务</p><p>mongodb_exporter.service</p><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#FFCB6B;">cat</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&lt;&lt;</span><span style="color:#89DDFF;">EOF</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&gt;</span><span style="color:#A6ACCD;">/usr/lib/systemd/system/mongodb_exporter.service</span></span>
<span class="line"><span style="color:#C3E88D;">[Unit]</span></span>
<span class="line"><span style="color:#C3E88D;">Description=mongodb_exporter</span></span>
<span class="line"><span style="color:#C3E88D;">Documentation=https://github.com/percona/mongodb_exporter</span></span>
<span class="line"><span style="color:#C3E88D;">After=network.target</span></span>
<span class="line"><span style="color:#C3E88D;">[Service]</span></span>
<span class="line"><span style="color:#C3E88D;">Type=simple</span></span>
<span class="line"><span style="color:#C3E88D;">User=root</span></span>
<span class="line"><span style="color:#C3E88D;">Environment=&quot;MONGODB_URI=mongodb://exporter:password@localhost:27017/admin&quot;</span></span>
<span class="line"><span style="color:#C3E88D;">ExecStart=/opt/module/mongodb_exporter/mongodb_exporter --log.level=error --collect-all --compatible-mode</span></span>
<span class="line"><span style="color:#C3E88D;">Restart=on-failure</span></span>
<span class="line"><span style="color:#C3E88D;">[Install]</span></span>
<span class="line"><span style="color:#C3E88D;">WantedBy=multi-user.target</span></span>
<span class="line"><span style="color:#89DDFF;">EOF</span></span></code></pre></div><p>启动 <strong>mongodb_exporter</strong></p><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#FFCB6B;">systemctl</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">daemon-reload</span></span>
<span class="line"><span style="color:#FFCB6B;">systemctl</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">start</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">mongodb_exporter.service</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 加⼊到开机⾃启动</span></span>
<span class="line"><span style="color:#FFCB6B;">systemctl</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">enable</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">mongodb_exporter.service</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 检查</span></span>
<span class="line"><span style="color:#FFCB6B;">systemctl</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">status</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">mongodb_exporter.service</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 启动不了检查⽇志</span></span>
<span class="line"><span style="color:#FFCB6B;">journalctl</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-u</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">mongodb_exporter.service</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-f</span></span></code></pre></div><h3 id="docker安装-3" tabindex="-1"><strong>docker</strong>安装 <a class="header-anchor" href="#docker安装-3" aria-label="Permalink to &quot;**docker**安装&quot;">​</a></h3><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#FFCB6B;">docker</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">run</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-d</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">--restart=always</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-p</span><span style="color:#A6ACCD;"> </span><span style="color:#F78C6C;">9216</span><span style="color:#C3E88D;">:9216</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-p</span><span style="color:#A6ACCD;"> </span><span style="color:#F78C6C;">17001</span><span style="color:#C3E88D;">:17001</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">--restart=always</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">--name=mongodb-exporter</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">bitnami/mongodb-exporter:latest</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">--collect-all</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">--compatible-mode</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">--mongodb.uri=mongodb://exporter:password@192.168.88.101:27017/admin</span><span style="color:#89DDFF;">?</span><span style="color:#C3E88D;">ssl=false</span></span></code></pre></div><p><strong>docker-compose</strong>⽅式</p><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#FFCB6B;">cat</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&gt;</span><span style="color:#C3E88D;">docker-compose.yaml</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&lt;&lt;</span><span style="color:#89DDFF;">EOF</span></span>
<span class="line"><span style="color:#C3E88D;">version: &#39;3.3&#39;</span></span>
<span class="line"><span style="color:#C3E88D;">services:</span></span>
<span class="line"><span style="color:#C3E88D;">  mongodb_exporter:</span></span>
<span class="line"><span style="color:#C3E88D;">    image: bitnami/mongodb-exporter:latest</span></span>
<span class="line"><span style="color:#C3E88D;">    container_name: mongodb_exporter</span></span>
<span class="line"><span style="color:#C3E88D;">    restart: always</span></span>
<span class="line"><span style="color:#C3E88D;">    environment:</span></span>
<span class="line"><span style="color:#C3E88D;">      MONGODB_URI: &quot;mongodb://exporter:password@192.168.11.62:27017/admin?ssl=false&quot;</span></span>
<span class="line"><span style="color:#C3E88D;">    command:</span></span>
<span class="line"><span style="color:#C3E88D;">      - &#39;--collect-all&#39;</span></span>
<span class="line"><span style="color:#C3E88D;">      - &#39;--compatible-mode&#39;</span></span>
<span class="line"><span style="color:#C3E88D;">    ports:</span></span>
<span class="line"><span style="color:#C3E88D;">      - &quot;9216:9216&quot;</span></span>
<span class="line"><span style="color:#89DDFF;">EOF</span></span></code></pre></div><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#FFCB6B;">docker-compose</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">up</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-d</span></span>
<span class="line"><span style="color:#FFCB6B;">docker</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">ps</span></span>
<span class="line"><span style="color:#FFCB6B;">docker</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">logs</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-f</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">mongodb_exporter</span></span></code></pre></div><h3 id="参数解释" tabindex="-1">参数解释 <a class="header-anchor" href="#参数解释" aria-label="Permalink to &quot;参数解释&quot;">​</a></h3><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304252138882.png" alt="image-20230425213854775" style="zoom:80%;"><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304252139294.png" alt="image-20230425213918190" style="zoom:80%;"><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304252139419.png" alt="image-20230425213937324" style="zoom:80%;"><h3 id="metrics地址" tabindex="-1">metrics地址 <a class="header-anchor" href="#metrics地址" aria-label="Permalink to &quot;metrics地址&quot;">​</a></h3><p>注：安装好Exporter后会暴露⼀个 <a href="http://ip" target="_blank" rel="noreferrer">http://ip</a>:端⼝/metrics 的HTTP服务</p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304252140985.png" alt="image-20230425214003923" style="zoom:80%;"><h2 id="prometheus配置-5" tabindex="-1">Prometheus配置 <a class="header-anchor" href="#prometheus配置-5" aria-label="Permalink to &quot;Prometheus配置&quot;">​</a></h2><p>配置prometheus去采集（拉取）mongodb_exporter的监控样本数据</p><div class="language-yml"><button title="Copy Code" class="copy"></button><span class="lang">yml</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#C3E88D;">cd /data/docker-prometheus</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 在scrape_configs(搜刮配置):下⾯增加如下配置：</span></span>
<span class="line"><span style="color:#C3E88D;">cat &gt;&gt; prometheus/prometheus.yml &lt;&lt; &quot;EOF&quot;</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#F07178;">job_name</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&#39;</span><span style="color:#C3E88D;">mongodb_exporter</span><span style="color:#89DDFF;">&#39;</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">static_configs</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#F07178;">targets</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">[</span><span style="color:#89DDFF;">&#39;</span><span style="color:#C3E88D;">192.168.88.101:9216</span><span style="color:#89DDFF;">&#39;</span><span style="color:#89DDFF;">]</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">labels</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">        </span><span style="color:#F07178;">instance</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">test服务器</span></span>
<span class="line"><span style="color:#C3E88D;">EOF</span></span></code></pre></div><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#676E95;font-style:italic;"># 重新加载配置</span></span>
<span class="line"><span style="color:#FFCB6B;">curl</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-X</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">POST</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">:9090/-/reload</span></span></code></pre></div><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304252141102.png" alt="image-20230425214144001" style="zoom:67%;"><h3 id="常用的监控指标" tabindex="-1">常⽤的监控指标 <a class="header-anchor" href="#常用的监控指标" aria-label="Permalink to &quot;常⽤的监控指标&quot;">​</a></h3><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#FFCB6B;">mongodb_ss_connections</span><span style="color:#A6ACCD;">{conn_type=</span><span style="color:#FFCB6B;">&quot;available&quot;</span><span style="color:#FFCB6B;">}</span><span style="color:#A6ACCD;"> </span><span style="color:#676E95;font-style:italic;"># 可⽤的连接总数</span></span>
<span class="line"><span style="color:#FFCB6B;">mongodb_ss_mem_virtual</span></span>
<span class="line"><span style="color:#FFCB6B;">mongodb_ss_mem_resident</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 关于 server status</span></span>
<span class="line"><span style="color:#FFCB6B;">mongodb_up</span><span style="color:#A6ACCD;"> </span><span style="color:#676E95;font-style:italic;"># 服务器是否在线</span></span>
<span class="line"><span style="color:#FFCB6B;">mongodb_ss_ok</span><span style="color:#A6ACCD;">{cl_id=</span><span style="color:#FFCB6B;">&quot;&quot;</span><span style="color:#FFCB6B;">,</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">cl_role=</span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">mongod</span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">,</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">rs_state=</span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">0</span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">}</span><span style="color:#A6ACCD;"> </span><span style="color:#676E95;font-style:italic;"># 服务器是否正常运⾏，取值为 1、0 。标签中记录</span></span>
<span class="line"><span style="color:#FFCB6B;">了</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">Cluster、ReplicaSet</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">的信息</span></span>
<span class="line"><span style="color:#FFCB6B;">mongodb_ss_uptime</span><span style="color:#A6ACCD;"> </span><span style="color:#676E95;font-style:italic;"># 服务器的运⾏时⻓，单位为秒</span></span>
<span class="line"><span style="color:#FFCB6B;">mongodb_ss_connections</span><span style="color:#A6ACCD;">{conn_type=</span><span style="color:#FFCB6B;">&quot;current&quot;</span><span style="color:#FFCB6B;">}</span><span style="color:#A6ACCD;"> </span><span style="color:#676E95;font-style:italic;"># 客户端连接数</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 关于主机</span></span>
<span class="line"><span style="color:#FFCB6B;">mongodb_sys_cpu_num_cpus</span><span style="color:#A6ACCD;"> </span><span style="color:#676E95;font-style:italic;"># 主机的 CPU 核数</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 关于 collection</span></span>
<span class="line"><span style="color:#FFCB6B;">mongodb_collstats_storageStats_count</span><span style="color:#A6ACCD;">{database=</span><span style="color:#FFCB6B;">&quot;xx&quot;</span><span style="color:#FFCB6B;">,</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">collection=</span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">xx</span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">}</span><span style="color:#A6ACCD;"> </span><span style="color:#676E95;font-style:italic;"># collection 全部⽂档的数量</span></span>
<span class="line"><span style="color:#FFCB6B;">mongodb_collstats_storageStats_size</span><span style="color:#A6ACCD;"> </span><span style="color:#676E95;font-style:italic;"># collection 全部⽂档的体积，单位 bytes</span></span>
<span class="line"><span style="color:#FFCB6B;">mongodb_collstats_storageStats_storageSize</span><span style="color:#A6ACCD;"> </span><span style="color:#676E95;font-style:italic;"># collection 全部⽂档占⽤的磁盘空间，默认会压缩</span></span>
<span class="line"><span style="color:#FFCB6B;">delta(mongodb_collstats_latencyStats_reads_ops[1m]</span><span style="color:#A6ACCD;">) </span><span style="color:#676E95;font-style:italic;"># collection 读操作的数量（每分钟）</span></span>
<span class="line"><span style="color:#FFCB6B;">delta(mongodb_collstats_latencyStats_reads_latency[1m]</span><span style="color:#A6ACCD;">) </span><span style="color:#676E95;font-style:italic;"># collection 读操作的延迟（每分钟），单位为微秒</span></span>
<span class="line"><span style="color:#FFCB6B;">mongodb_collstats_latencyStats_write_ops</span></span>
<span class="line"><span style="color:#FFCB6B;">mongodb_collstats_latencyStats_write_latency</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 关于 index</span></span>
<span class="line"><span style="color:#FFCB6B;">mongodb_collstats_storageStats_nindexes</span><span style="color:#A6ACCD;"> </span><span style="color:#676E95;font-style:italic;"># collection 的 index 数量</span></span>
<span class="line"><span style="color:#FFCB6B;">mongodb_collstats_storageStats_totalIndexSize</span><span style="color:#A6ACCD;"> </span><span style="color:#676E95;font-style:italic;"># collection 的 index 占⽤的磁盘空间</span></span>
<span class="line"><span style="color:#FFCB6B;">delta(mongodb_indexstats_accesses_ops[1m]</span><span style="color:#A6ACCD;">) </span><span style="color:#676E95;font-style:italic;"># index 被访问次数</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 关于操作</span></span>
<span class="line"><span style="color:#FFCB6B;">delta(mongodb_ss_opcounters[1m]</span><span style="color:#A6ACCD;">) </span><span style="color:#676E95;font-style:italic;"># 执⾏各种操作的数量</span></span>
<span class="line"><span style="color:#FFCB6B;">delta(mongodb_ss_opLatencies_latency[1m]</span><span style="color:#A6ACCD;">) </span><span style="color:#676E95;font-style:italic;"># 执⾏各种操作的延迟，单位为微秒</span></span>
<span class="line"><span style="color:#FFCB6B;">delta(mongodb_ss_metrics_document[1m]</span><span style="color:#A6ACCD;">) </span><span style="color:#676E95;font-style:italic;"># 各种⽂档的变化数量</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 关于锁</span></span>
<span class="line"><span style="color:#FFCB6B;">delta(mongodb_ss_locks_acquireCount</span><span style="color:#A6ACCD;">{lock_mode=</span><span style="color:#FFCB6B;">&quot;w&quot;</span><span style="color:#FFCB6B;">}[1m]</span><span style="color:#A6ACCD;">) </span><span style="color:#676E95;font-style:italic;"># 新加锁的数量。R 表示共享锁，W 表示独占锁，r表示意向共享锁，w 表示意向独占锁</span></span>
<span class="line"><span style="color:#FFCB6B;">mongodb_ss_globalLock_currentQueue</span><span style="color:#A6ACCD;">{count_type=</span><span style="color:#FFCB6B;">&quot;total&quot;</span><span style="color:#FFCB6B;">}</span><span style="color:#A6ACCD;"> </span><span style="color:#676E95;font-style:italic;"># 被锁阻塞的操作数</span></span></code></pre></div><h3 id="触发器配置-3" tabindex="-1">触发器配置 <a class="header-anchor" href="#触发器配置-3" aria-label="Permalink to &quot;触发器配置&quot;">​</a></h3><p>Prometheus配置</p><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#676E95;font-style:italic;"># 报警(触发器)配置</span></span>
<span class="line"><span style="color:#FFCB6B;">rule_files:</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#FFCB6B;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">alert.yml</span><span style="color:#89DDFF;">&quot;</span><span style="color:#A6ACCD;"> </span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#FFCB6B;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">rules/*.yml</span><span style="color:#89DDFF;">&quot;</span></span></code></pre></div><p><strong>mongodb</strong>触发器（告警规则）</p><p>因mongo单点，所以未配置复制触发器</p><div class="language-yml"><button title="Copy Code" class="copy"></button><span class="lang">yml</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#F07178;">groups</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#F07178;">name</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">PerconaMongodbExporter</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#F07178;">rules</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#F07178;">alert</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">MongodbDown</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">expr</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&#39;</span><span style="color:#C3E88D;">mongodb_up == 0</span><span style="color:#89DDFF;">&#39;</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">for</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">0m</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">labels</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">        </span><span style="color:#F07178;">severity</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">critical</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">annotations</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">        </span><span style="color:#F07178;">summary</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">MongoDB Down 容器: $labels.instance</span><span style="color:#89DDFF;">&quot;</span></span>
<span class="line"><span style="color:#A6ACCD;">        </span><span style="color:#F07178;">description</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">MongoDB 容器 is down, 当前值:{{ $value }}</span><span style="color:#89DDFF;">&quot;</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#F07178;">alert</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">MongodbNumberCursorsOpen</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">expr</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&#39;</span><span style="color:#C3E88D;">mongodb_ss_metrics_cursor_open{csr_type=&quot;total&quot;} &gt; 10 * 1000</span><span style="color:#89DDFF;">&#39;</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">for</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">2m</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">labels</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">        </span><span style="color:#F07178;">severity</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">warning</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">annotations</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">        </span><span style="color:#F07178;">summary</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">MongoDB 数字有标打开告警 容器: $labels.instance</span><span style="color:#89DDFF;">&quot;</span></span>
<span class="line"><span style="color:#A6ACCD;">        </span><span style="color:#F07178;">description</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">MongoDB 为客户端打开的游标过多 &gt; 10k, 当前值:{{ $value }}</span><span style="color:#89DDFF;">&quot;</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#F07178;">alert</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">MongodbCursorsTimeouts</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">expr</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&#39;</span><span style="color:#C3E88D;">increase(mongodb_ss_metrics_cursor_timedOut[1m]) &gt; 100</span><span style="color:#89DDFF;">&#39;</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">for</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">2m</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">labels</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">        </span><span style="color:#F07178;">severity</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">warning</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">annotations</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">        </span><span style="color:#F07178;">summary</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">MongoDB 游标超时 容器: $labels.instance</span><span style="color:#89DDFF;">&quot;</span></span>
<span class="line"><span style="color:#A6ACCD;">        </span><span style="color:#F07178;">description</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">太多游标超时, 当前值:{{ $value }}</span><span style="color:#89DDFF;">&quot;</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#F07178;">alert</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">MongodbTooManyConnections</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">expr</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&#39;</span><span style="color:#C3E88D;">avg by(instance) (rate(mongodb_ss_connections{conn_type=&quot;current&quot;}[1m])) / avg by(instance) (sum (mongodb_ss_connections) by (instance)) * 100 &gt; 80</span><span style="color:#89DDFF;">&#39;</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">for</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">2m</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">labels</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">        </span><span style="color:#F07178;">severity</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">warning</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">annotations</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">        </span><span style="color:#F07178;">summary</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">MongoDB 太多连接 容器: $labels.instance</span><span style="color:#89DDFF;">&quot;</span></span>
<span class="line"><span style="color:#A6ACCD;">        </span><span style="color:#F07178;">description</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">MongoDB 连接数 &gt; 80%, 当前值:{{ $value }}</span><span style="color:#89DDFF;">&quot;</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#F07178;">alert</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">MongodbVirtualMemoryUsage</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">expr</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&#39;</span><span style="color:#C3E88D;">(sum(mongodb_ss_mem_virtual) BY (instance) / sum(mongodb_ss_mem_resident) BY (instance)) &gt; 3</span><span style="color:#89DDFF;">&#39;</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">for</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">2m</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">labels</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">        </span><span style="color:#F07178;">severity</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">warning</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">annotations</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">        </span><span style="color:#F07178;">summary</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">MongoDB虚拟内存使⽤告警 容器: $labels.instance</span><span style="color:#89DDFF;">&quot;</span></span>
<span class="line"><span style="color:#A6ACCD;">        </span><span style="color:#F07178;">description</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">虚拟内存使⽤过⾼, 当前值:{{ $value }}</span><span style="color:#89DDFF;">&quot;</span></span></code></pre></div><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#FFCB6B;">curl</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-X</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">POST</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">:9090/-/reload</span></span></code></pre></div><p>检查：<a href="http://192.168.11.61:9090/alerts?search=" target="_blank" rel="noreferrer">http://192.168.11.61:9090/alerts?search=</a></p><p>或：<a href="http://192.168.11.61:9090/rules" target="_blank" rel="noreferrer">http://192.168.11.61:9090/rules</a></p><h2 id="dashboard-4" tabindex="-1">dashboard <a class="header-anchor" href="#dashboard-4" aria-label="Permalink to &quot;dashboard&quot;">​</a></h2><p>grafana展示prometheus从mongodb_exporter收集到的的数据</p><p><a href="https://github.com/percona/grafana-dashboards/tree/main/dashboards/MongoDB" target="_blank" rel="noreferrer">https://github.com/percona/grafana-dashboards/tree/main/dashboards/MongoDB</a></p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304271734110.png" alt="image-20230427173421002" style="zoom:80%;"><h1 id="域名监控" tabindex="-1">域名监控 <a class="header-anchor" href="#域名监控" aria-label="Permalink to &quot;域名监控&quot;">​</a></h1><p>域名的监控通过 domain_exporter 来完成，域名过期时间监控</p><p>domain_exporter：<a href="https://github.com/caarlos0/domain_exporter/releases" target="_blank" rel="noreferrer">https://github.com/caarlos0/domain_exporter/releases</a></p><h2 id="二进制安装-5" tabindex="-1">二进制安装 <a class="header-anchor" href="#二进制安装-5" aria-label="Permalink to &quot;二进制安装&quot;">​</a></h2><p><a href="https://prometheus.io/download/" target="_blank" rel="noreferrer">https://prometheus.io/download/</a></p><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#FFCB6B;">wget</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">https://github.com/caarlos0/domain_exporter/releases/download/v1.20.0/domain</span></span>
<span class="line"><span style="color:#FFCB6B;">_exporter_1.20.0_linux_amd64.tar.gz</span></span>
<span class="line"></span>
<span class="line"><span style="color:#FFCB6B;">tar</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-zxvf</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">domain_exporter_1.20.0_linux_amd64.tar.gz</span></span>
<span class="line"><span style="color:#FFCB6B;">mkdir</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">/opt/prometheus</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-p</span></span>
<span class="line"><span style="color:#FFCB6B;">mv</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">domain_exporter_1.20.0_linux_amd64</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">/opt/prometheus/domain_exporter</span></span></code></pre></div><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#FFCB6B;">useradd</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-M</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-s</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">/usr/sbin/nologin</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">prometheus</span></span>
<span class="line"><span style="color:#FFCB6B;">chown</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">prometheus:prometheus</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-R</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">/opt/prometheus</span></span></code></pre></div><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#FFCB6B;">cat</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&lt;&lt;</span><span style="color:#A6ACCD;">&quot;</span><span style="color:#89DDFF;">EOF</span><span style="color:#A6ACCD;">&quot; </span><span style="color:#89DDFF;">&gt;</span><span style="color:#A6ACCD;">/etc/systemd/system/domain_exporter.service</span></span>
<span class="line"><span style="color:#C3E88D;">[Unit]</span></span>
<span class="line"><span style="color:#C3E88D;">Description=domain_exporter </span></span>
<span class="line"><span style="color:#C3E88D;">After=network.target</span></span>
<span class="line"><span style="color:#C3E88D;">[Service]</span></span>
<span class="line"><span style="color:#C3E88D;">Type=simple</span></span>
<span class="line"><span style="color:#C3E88D;">User=prometheus</span></span>
<span class="line"><span style="color:#C3E88D;">Group=prometheus</span></span>
<span class="line"><span style="color:#C3E88D;">ExecStart=/opt/prometheus/domain_exporter/domain_exporter </span></span>
<span class="line"><span style="color:#C3E88D;">Restart=on-failure</span></span>
<span class="line"><span style="color:#C3E88D;">[Install]</span></span>
<span class="line"><span style="color:#C3E88D;">WantedBy=multi-user.target</span></span>
<span class="line"><span style="color:#89DDFF;">EOF</span></span></code></pre></div><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#FFCB6B;">systemctl</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">daemon-reload</span></span>
<span class="line"><span style="color:#FFCB6B;">systemctl</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">start</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">domain_exporter</span></span>
<span class="line"><span style="color:#FFCB6B;">systemctl</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">enable</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">domain_exporter</span></span>
<span class="line"><span style="color:#FFCB6B;">systemctl</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">status</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">domain_exporter</span></span>
<span class="line"><span style="color:#FFCB6B;">journalctl</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-u</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">domain_exporter</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-f</span></span></code></pre></div><h2 id="docker安装⭐-2" tabindex="-1">Docker安装⭐ <a class="header-anchor" href="#docker安装⭐-2" aria-label="Permalink to &quot;Docker安装⭐&quot;">​</a></h2><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#FFCB6B;">docker</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">run</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-d</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">--restart=always</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">--name</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">domain_exporter</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-p</span><span style="color:#A6ACCD;"> </span><span style="color:#F78C6C;">9222</span><span style="color:#C3E88D;">:9222</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">caarlos0/domain_exporter</span></span></code></pre></div><h2 id="prometheus设置" tabindex="-1">Prometheus设置 <a class="header-anchor" href="#prometheus设置" aria-label="Permalink to &quot;Prometheus设置&quot;">​</a></h2><div class="language-yml"><button title="Copy Code" class="copy"></button><span class="lang">yml</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#F07178;">job_name</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">domain</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">scrape_interval</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">15s</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">metrics_path</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">/probe</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">relabel_configs</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#F07178;">source_labels</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">[</span><span style="color:#C3E88D;">__address__</span><span style="color:#89DDFF;">]</span></span>
<span class="line"><span style="color:#A6ACCD;">        </span><span style="color:#F07178;">target_label</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">__param_target</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#F07178;">target_label</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">__address__</span></span>
<span class="line"><span style="color:#A6ACCD;">        </span><span style="color:#F07178;">replacement</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">192.168.88.101:9222</span><span style="color:#A6ACCD;"> </span><span style="color:#676E95;font-style:italic;"># domain_exporter address</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">static_configs</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#F07178;">targets</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">        </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">qq.com</span></span>
<span class="line"><span style="color:#A6ACCD;">        </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">baidu.cn</span></span></code></pre></div><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#676E95;font-style:italic;"># 重新加载配置</span></span>
<span class="line"><span style="color:#FFCB6B;">curl</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-X</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">POST</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">:9090/-/reload</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 检查</span></span>
<span class="line"><span style="color:#FFCB6B;">http://192.168.11.61:9090/targets?search</span><span style="color:#A6ACCD;">=</span></span>
<span class="line"><span style="color:#FFCB6B;">http://192.168.11.62:9222/</span></span></code></pre></div><h2 id="常用监控项目" tabindex="-1">常⽤监控项⽬ <a class="header-anchor" href="#常用监控项目" aria-label="Permalink to &quot;常⽤监控项⽬&quot;">​</a></h2><div class="language-"><button title="Copy Code" class="copy"></button><span class="lang"></span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#A6ACCD;">domain_expiry_days 域名到期时间</span></span>
<span class="line"><span style="color:#A6ACCD;"></span></span>
<span class="line"><span style="color:#A6ACCD;">domain_probe_success 域名检测状态</span></span></code></pre></div><h2 id="触发器-1" tabindex="-1">触发器 <a class="header-anchor" href="#触发器-1" aria-label="Permalink to &quot;触发器&quot;">​</a></h2><p>Prometheus配置</p><div class="language-yml"><button title="Copy Code" class="copy"></button><span class="lang">yml</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#676E95;font-style:italic;"># 报警(触发器)配置</span></span>
<span class="line"><span style="color:#F07178;">rule_files</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">alert.yml</span><span style="color:#89DDFF;">&quot;</span><span style="color:#A6ACCD;"> </span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">rules/*.yml</span><span style="color:#89DDFF;">&quot;</span></span></code></pre></div><p>添加<strong>domain</strong>触发器（告警规则）</p><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#FFCB6B;">groups:</span></span>
<span class="line"><span style="color:#FFCB6B;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">name:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">domain</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#FFCB6B;">rules:</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#FFCB6B;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">alert:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">域名检测失败</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#FFCB6B;">expr:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">domain_probe_success</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">==</span><span style="color:#A6ACCD;"> </span><span style="color:#F78C6C;">0</span></span>
<span class="line"><span style="color:#A6ACCD;">    for: 2h</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#FFCB6B;">labels:</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#FFCB6B;">severity:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">warning</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#FFCB6B;">annotations:</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#FFCB6B;">summary:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&#39;</span><span style="color:#C3E88D;">{{ $labels.instance }}</span><span style="color:#89DDFF;">&#39;</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#FFCB6B;">description:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&#39;</span><span style="color:#C3E88D;">{{ $labels.domain }}域名检测失败</span><span style="color:#89DDFF;">&#39;</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#FFCB6B;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">alert:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">域名过期</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#FFCB6B;">expr:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">domain_expiry_days</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&lt;</span><span style="color:#A6ACCD;"> </span><span style="color:#F78C6C;">30</span></span>
<span class="line"><span style="color:#A6ACCD;">    for: 2h</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#FFCB6B;">labels:</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#FFCB6B;">severity:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">warning</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#FFCB6B;">annotations:</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#FFCB6B;">summary:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&#39;</span><span style="color:#C3E88D;">{{ $labels.instance }}</span><span style="color:#89DDFF;">&#39;</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#FFCB6B;">description:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&#39;</span><span style="color:#C3E88D;">{{ $labels.domain }}将在30天后过期</span><span style="color:#89DDFF;">&#39;</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#FFCB6B;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">alert:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">域名过期</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#FFCB6B;">expr:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">domain_expiry_days</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&lt;</span><span style="color:#A6ACCD;"> </span><span style="color:#F78C6C;">5</span></span>
<span class="line"><span style="color:#A6ACCD;">    for: 2h</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#FFCB6B;">labels:</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#FFCB6B;">severity:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">page</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#FFCB6B;">annotations:</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#FFCB6B;">summary:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&#39;</span><span style="color:#C3E88D;">{{ $labels.instance }}</span><span style="color:#89DDFF;">&#39;</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#FFCB6B;">description:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&#39;</span><span style="color:#C3E88D;">{{ $labels.domain }}将在5天后过期</span><span style="color:#89DDFF;">&#39;</span></span></code></pre></div><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#676E95;font-style:italic;"># 重新加载配置</span></span>
<span class="line"><span style="color:#FFCB6B;">./promtool</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">check</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">rules</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">rules/linux.yml</span></span>
<span class="line"><span style="color:#FFCB6B;">curl</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-X</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">POST</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">:9090/-/reload</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 检查</span></span>
<span class="line"><span style="color:#FFCB6B;">http://192.168.11.61:9090/alerts?search</span><span style="color:#A6ACCD;">=</span></span></code></pre></div><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304281516932.png" alt="image-20230428151616853" style="zoom:80%;"><h2 id="doshboard" tabindex="-1">Doshboard <a class="header-anchor" href="#doshboard" aria-label="Permalink to &quot;Doshboard&quot;">​</a></h2><p><a href="https://grafana.com/grafana/dashboards/14605" target="_blank" rel="noreferrer">https://grafana.com/grafana/dashboards/14605</a></p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304261425484.png" alt="image-20230426142556412" style="zoom:80%;"><p>找到右边的Column Styles，在找到“域名”这列，把 instance 修改为 domain 如下图</p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304281520778.png" alt="image-20230428152027695" style="zoom:80%;"><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304261426381.png" alt="image-20230426142626295" style="zoom:80%;"><h1 id="docker监控" tabindex="-1">Docker监控 <a class="header-anchor" href="#docker监控" aria-label="Permalink to &quot;Docker监控&quot;">​</a></h1><h2 id="docker命令" tabindex="-1">Docker命令 <a class="header-anchor" href="#docker命令" aria-label="Permalink to &quot;Docker命令&quot;">​</a></h2><p>为了能够获取到Docker容器的运⾏状态，⽤户可以通过Docker的stats命令获取到当前主机上运⾏容器的统计信息，可以查看容器的CPU利⽤率、内存使⽤量、⽹络IO总量以及磁盘IO总量等信息。</p><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#FFCB6B;">docker</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">stats</span></span></code></pre></div><p>除了使⽤命令以外，⽤户还可以通过Docker提供的HTTP API查看容器详细的监控统计信息。</p><h2 id="cadvisor" tabindex="-1">CAdvisor <a class="header-anchor" href="#cadvisor" aria-label="Permalink to &quot;CAdvisor&quot;">​</a></h2><p>CAdvisor是Google开源的⼀款⽤于展示和分析容器运⾏状态的可视化⼯具。通过在主机上运⾏CAdvisor⽤户可以轻松的获取到当前主机上容器的运⾏统计信息，并以图表的形式向⽤户展示。</p><h3 id="docker版安装⭐" tabindex="-1">Docker版安装⭐ <a class="header-anchor" href="#docker版安装⭐" aria-label="Permalink to &quot;Docker版安装⭐&quot;">​</a></h3><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#FFCB6B;">docker</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">run</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-d</span><span style="color:#A6ACCD;"> \</span></span>
<span class="line"><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">--restart=always</span><span style="color:#A6ACCD;"> \</span></span>
<span class="line"><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">--volume=/:/rootfs:ro</span><span style="color:#A6ACCD;"> \</span></span>
<span class="line"><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">--volume=/var/run:/var/run:rw</span><span style="color:#A6ACCD;"> \</span></span>
<span class="line"><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">--volume=/sys:/sys:ro</span><span style="color:#A6ACCD;"> \</span></span>
<span class="line"><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">--volume=/var/lib/docker/:/var/lib/docker:ro</span><span style="color:#A6ACCD;"> \</span></span>
<span class="line"><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">--publish=8080:8080</span><span style="color:#A6ACCD;"> \</span></span>
<span class="line"><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">--name=cadvisor</span><span style="color:#A6ACCD;"> \</span></span>
<span class="line"><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">google/cadvisor:latest</span></span></code></pre></div><h3 id="docker-compose版安装" tabindex="-1">Docker-compose版安装 <a class="header-anchor" href="#docker-compose版安装" aria-label="Permalink to &quot;Docker-compose版安装&quot;">​</a></h3><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#FFCB6B;">mkdir</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">/data/cadvisor</span></span>
<span class="line"><span style="color:#82AAFF;">cd</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">/data/cadvisor</span></span></code></pre></div><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#676E95;font-style:italic;"># 通过cat新建docker-compose.yaml⽂件</span></span>
<span class="line"><span style="color:#FFCB6B;">cat</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&gt;</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">docker-compose.yaml</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&lt;&lt;</span><span style="color:#A6ACCD;">&quot;</span><span style="color:#89DDFF;">EOF</span><span style="color:#A6ACCD;">&quot;</span></span>
<span class="line"><span style="color:#C3E88D;">version: &#39;3.3&#39;</span></span>
<span class="line"><span style="color:#C3E88D;">  cadvisor:</span></span>
<span class="line"><span style="color:#C3E88D;">    image: google/cadvisor:latest</span></span>
<span class="line"><span style="color:#C3E88D;">    container_name: cadvisor</span></span>
<span class="line"><span style="color:#C3E88D;">    restart: always</span></span>
<span class="line"><span style="color:#C3E88D;">    volumes:</span></span>
<span class="line"><span style="color:#C3E88D;">      - /:/rootfs:ro</span></span>
<span class="line"><span style="color:#C3E88D;">      - /var/run:/var/run:rw</span></span>
<span class="line"><span style="color:#C3E88D;">      - /sys:/sys:ro</span></span>
<span class="line"><span style="color:#C3E88D;">      - /var/lib/docker/:/var/lib/docker:ro</span></span>
<span class="line"><span style="color:#C3E88D;">    ports:</span></span>
<span class="line"><span style="color:#C3E88D;">      - 8080:8080</span></span></code></pre></div><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#FFCB6B;">docker-compose</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">up</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-d</span></span>
<span class="line"><span style="color:#FFCB6B;">docker</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">ps</span></span></code></pre></div><p>访问：:8080可以查看，当前主机上容器的运⾏状态，如下所示</p><p>访问：:8080/metrics即可获取到标准的Prometheus监控样本输出</p><h2 id="prometheus配置-6" tabindex="-1">Prometheus配置 <a class="header-anchor" href="#prometheus配置-6" aria-label="Permalink to &quot;Prometheus配置&quot;">​</a></h2><p>配置prometheus去采集（拉取）cAdvisor的监控样本数据</p><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#82AAFF;">cd</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">/data/docker-prometheus</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 在scrape_configs(搜刮配置):下⾯增加如下配置：</span></span>
<span class="line"><span style="color:#FFCB6B;">cat</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&gt;&gt;</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">prometheus/prometheus.yml</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&lt;&lt;</span><span style="color:#A6ACCD;"> &quot;</span><span style="color:#89DDFF;">EOF</span><span style="color:#A6ACCD;">&quot;</span></span>
<span class="line"><span style="color:#C3E88D;">  - job_name: &#39;cadvisor&#39;</span></span>
<span class="line"><span style="color:#C3E88D;">    static_configs:</span></span>
<span class="line"><span style="color:#C3E88D;">    - targets: [&#39;192.168.88.101:8080&#39;]</span></span>
<span class="line"><span style="color:#C3E88D;">      labels:</span></span>
<span class="line"><span style="color:#C3E88D;">        instance: node1</span></span>
<span class="line"><span style="color:#89DDFF;">EOF</span></span></code></pre></div><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#676E95;font-style:italic;"># 重新加载配置</span></span>
<span class="line"><span style="color:#FFCB6B;">curl</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-X</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">POST</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">:9090/-/reload</span></span></code></pre></div><p>启动完成后，可以在Prometheus UI中查看到当前所有的Target状态：<a href="http://192.168.88.101:9090/targets?search=" target="_blank" rel="noreferrer">http://192.168.88.101:9090/targets?search=</a></p><h2 id="常用监控指标-5" tabindex="-1">常⽤监控指标 <a class="header-anchor" href="#常用监控指标-5" aria-label="Permalink to &quot;常⽤监控指标&quot;">​</a></h2><p>下⾯表格中列举了⼀些CAdvisor中获取到的典型监控指标：container_</p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304261448453.png" alt="image-20230426144837352" style="zoom:80%;"><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304261448444.png" alt="image-20230426144853374" style="zoom:80%;"><h2 id="触发器配置-4" tabindex="-1">触发器配置 <a class="header-anchor" href="#触发器配置-4" aria-label="Permalink to &quot;触发器配置&quot;">​</a></h2><p>Prometheus配置</p><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#676E95;font-style:italic;"># 报警(触发器)配置</span></span>
<span class="line"><span style="color:#FFCB6B;">rule_files:</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#FFCB6B;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">alert.yml</span><span style="color:#89DDFF;">&quot;</span><span style="color:#A6ACCD;"> </span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#FFCB6B;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">rules/*.yml</span><span style="color:#89DDFF;">&quot;</span></span></code></pre></div><p>添加<strong>docker</strong>触发器（告警规则）</p><div class="language-yml"><button title="Copy Code" class="copy"></button><span class="lang">yml</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#F07178;">groups</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#F07178;">name</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">DockerContainers</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#F07178;">rules</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#F07178;">alert</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">ContainerKilled</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">expr</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">time() - container_last_seen &gt; 60</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">for</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">0m</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">labels</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">severity</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">warning</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">annotations</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">isummary</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">Docker容器被杀死 容器: $labels.instance</span><span style="color:#89DDFF;">&quot;</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">description</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">{{ $value }}个容器消失了</span><span style="color:#89DDFF;">&quot;</span></span>
<span class="line"><span style="color:#89DDFF;">  </span><span style="color:#676E95;font-style:italic;"># This rule can be very noisy in dynamic infra with legitimate container start/stop/deployment.</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#F07178;">alert</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">ContainerAbsent</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">expr</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">absent(container_last_seen)</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">for</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">5m</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">labels</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">severity</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">warning</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">annotations</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">summary</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">无容器 容器: $labels.instance</span><span style="color:#89DDFF;">&quot;</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">description</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">5分钟检查容器不存在，值为：{{ $value }}</span><span style="color:#89DDFF;">&quot;</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#F07178;">alert</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">ContainerCpuUsage</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">expr</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">(sum(rate(container_cpu_usage_seconds_total{name!=&quot;&quot;}[3m])) BY (instance, name) * 100) &gt; 300</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">for</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">2m</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">labels</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">severity</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">warning</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">annotations</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">summary</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">容器cpu使用率告警 容器: $labels.instance</span><span style="color:#89DDFF;">&quot;</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">description</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">容器cpu使用率超过300%，当前值为：{{ $value }}</span><span style="color:#89DDFF;">&quot;</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#F07178;">alert</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">ContainerMemoryUsage</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">expr</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">(sum(container_memory_working_set_bytes{name!=&quot;&quot;}) BY (instance, name) / sum(container_spec_memory_limit_bytes &gt; 0) BY (instance, name) * 100) &gt; 80</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">for</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">2m</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">labels</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">severity</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">warning</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">annotations</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">summary</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">容器内存使用率告警 容器: $labels.instance</span><span style="color:#89DDFF;">&quot;</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">description</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">容器内存使用率超过80%，当前值为：{{ $value }}</span><span style="color:#89DDFF;">&quot;</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#F07178;">alert</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">ContainerVolumeIoUsage</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">expr</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">(sum(container_fs_io_current{name!=&quot;&quot;}) BY (instance, name) * 100) &gt; 80</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">for</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">2m</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">labels</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">severity</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">warning</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">annotations</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">summary</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">容器存储io使用率告警 容器: $labels.instance</span><span style="color:#89DDFF;">&quot;</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">description</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">容器存储io使用率超过 80%，当前值为：{{ $value }}</span><span style="color:#89DDFF;">&quot;</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#F07178;">alert</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">ContainerHighThrottleRate</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">expr</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">rate(container_cpu_cfs_throttled_seconds_total[3m]) &gt; 1</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">for</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">2m</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">labels</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">severity</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">warning</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">annotations</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">summary</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">容器限制告警 容器: $labels.instance</span><span style="color:#89DDFF;">&quot;</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">description</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">容器被限制，当前值为：{{ $value }}</span><span style="color:#89DDFF;">&quot;</span></span></code></pre></div><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#676E95;font-style:italic;"># 重新加载配置</span></span>
<span class="line"><span style="color:#FFCB6B;">./promtool</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">check</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">rules</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">rules/linux.yml</span></span>
<span class="line"><span style="color:#FFCB6B;">curl</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-X</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">POST</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">:9090/-/reload</span></span>
<span class="line"><span style="color:#FFCB6B;">curl</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-X</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">POST</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">http://node1:9093/-/reload</span></span></code></pre></div><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304281527085.png" alt="image-20230428152723984" style="zoom:80%;"><h2 id="dashboard-5" tabindex="-1">dashboard <a class="header-anchor" href="#dashboard-5" aria-label="Permalink to &quot;dashboard&quot;">​</a></h2><p>grafana展示prometheus收集到的cadvisor的数据192.168.88.101:3000</p><p><a href="https://grafana.com/grafana/dashboards/11600-docker-container/" target="_blank" rel="noreferrer">https://grafana.com/grafana/dashboards/11600-docker-container/</a></p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304281532189.png" alt="image-20230428153214022" style="zoom:80%;"><h1 id="etcd监控" tabindex="-1">etcd监控 <a class="header-anchor" href="#etcd监控" aria-label="Permalink to &quot;etcd监控&quot;">​</a></h1><p>使⽤kube-prometheus-stack安装好prometheus，并对整个K8S集群做好监控。</p><h3 id="获取etcd证书" tabindex="-1">获取etcd证书 <a class="header-anchor" href="#获取etcd证书" aria-label="Permalink to &quot;获取etcd证书&quot;">​</a></h3><p><strong>etcd</strong> 证书</p><p>对于 etcd 集群⼀般情况下，为了安全都会开启 https 证书认证的⽅式，所以要想让 Prometheus 访问到</p><p>etcd 集群的监控数据，就需要提供相应的证书校验</p><p>证书路径：</p><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#FFCB6B;">vim</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">/etc/kubernetes/manifests/kube-apiserver.yaml</span></span></code></pre></div><p>得到</p><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#FFCB6B;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">--etcd-cafile=/etc/ssl/etcd/ssl/ca.pem</span></span>
<span class="line"><span style="color:#FFCB6B;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">--etcd-certfile=/etc/ssl/etcd/ssl/node-k8s.pem</span></span>
<span class="line"><span style="color:#FFCB6B;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">--etcd-keyfile=/etc/ssl/etcd/ssl/node-k8s-key.pem</span></span>
<span class="line"><span style="color:#FFCB6B;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">--etcd-servers=https://192.168.11.65:2379</span></span></code></pre></div><p>可以看到是跟计算机名有关系的。通过curl检查</p><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#FFCB6B;">curl</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-k</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">--cacert</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">/etc/ssl/etcd/ssl/ca.pem</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">--cert</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">/etc/ssl/etcd/ssl/node-k8s.pem</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">--key</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">/etc/ssl/etcd/ssl/node-k8s-key.pem</span></span>
<span class="line"></span>
<span class="line"><span style="color:#FFCB6B;">https://localhost:2379/metrics</span></span></code></pre></div><p>说明etcd ⾃带metrics（监控样本数据）</p><h3 id="创建secret-保密字典" tabindex="-1">创建<strong>secret</strong>（保密字典） <a class="header-anchor" href="#创建secret-保密字典" aria-label="Permalink to &quot;创建**secret**（保密字典）&quot;">​</a></h3><p>pem ⽂件根据实际修改</p><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#FFCB6B;">kubectl</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-n</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">monitoring</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">create</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">secret</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">generic</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">etcd-certs</span><span style="color:#A6ACCD;"> \</span></span>
<span class="line"><span style="color:#A6ACCD;">--from-file=/etc/ssl/etcd/ssl/ca.pem \</span></span>
<span class="line"><span style="color:#A6ACCD;">--from-file=/etc/ssl/etcd/ssl/node-k8s.pem \</span></span>
<span class="line"><span style="color:#A6ACCD;">--from-file=/etc/ssl/etcd/ssl/node-k8s-key.pem</span></span></code></pre></div><div class="language-"><button title="Copy Code" class="copy"></button><span class="lang"></span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#A6ACCD;">kubectl -n monitoring get secret etcd-certs -oyaml</span></span></code></pre></div><h3 id="kube-prometheus-stack开启etcd监控" tabindex="-1">kube-prometheus-stack开启etcd监控 <a class="header-anchor" href="#kube-prometheus-stack开启etcd监控" aria-label="Permalink to &quot;kube-prometheus-stack开启etcd监控&quot;">​</a></h3><p>修改配置⽂件，开启etcd监控</p><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#FFCB6B;">vim</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">kube-prometheus-stack/values.yaml</span></span></code></pre></div><p>修改如下：</p><div class="language-yml"><button title="Copy Code" class="copy"></button><span class="lang">yml</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#F07178;">kubeEtcd</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#F07178;">enabled</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#FF9CAC;">true</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#F07178;">endpoints</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#89DDFF;">  </span><span style="color:#676E95;font-style:italic;">#因为我们的etcd安装到宿主机上的，所以要指定宿主机ip，ip根据实际修改。</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#F78C6C;">192.168.11.65</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#F07178;">service</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">enabled</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#FF9CAC;">true</span></span>
<span class="line"><span style="color:#89DDFF;">    </span><span style="color:#676E95;font-style:italic;">#注，我的etcd端⼝为2379，根据实际修改</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">port</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#F78C6C;">2379</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">targetPort</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#F78C6C;">2379</span></span>
<span class="line"><span style="color:#A6ACCD;"> </span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#F07178;">serviceMonitor</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">enabled</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#FF9CAC;">true</span></span>
<span class="line"><span style="color:#89DDFF;">    </span><span style="color:#676E95;font-style:italic;">#https请求</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">scheme</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">https</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">insecureSkipVerify</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#FF9CAC;">true</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">serverName</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;&quot;</span></span>
<span class="line"><span style="color:#89DDFF;">    </span><span style="color:#676E95;font-style:italic;">#指定证路径</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">caFile</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">/etc/prometheus/secrets/etcd-certs/ca.pem</span><span style="color:#89DDFF;">&quot;</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">certFile</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">/etc/prometheus/secrets/etcd-certs/node-k8s.pem</span><span style="color:#89DDFF;">&quot;</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">keyFile</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">/etc/prometheus/secrets/etcd-certs/node-k8s-key.pem</span><span style="color:#89DDFF;">&quot;</span></span>
<span class="line"><span style="color:#A6ACCD;"> </span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#F07178;">prometheusSpec</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#89DDFF;">   </span><span style="color:#676E95;font-style:italic;"># 把secret挂载到prometheus的pod⾥⾯</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">volumes</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#F07178;">name</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">cert-vol</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">secret</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">        </span><span style="color:#F07178;">secretName</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">etcd-certs</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">volumeMounts</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#F07178;">name</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">cert-vol</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">mountPath</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">/etc/prometheus/secrets/etcd-certs</span><span style="color:#89DDFF;">&quot;</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">readOnly</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#FF9CAC;">true</span></span></code></pre></div><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#676E95;font-style:italic;"># 更新配置，删除服务prometheus-kube-prometheus-kube-etcd</span></span>
<span class="line"><span style="color:#FFCB6B;">kubectl</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">delete</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">svc</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">prometheus-kube-prometheus-kube-etcd</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-n</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">kube-system</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 在执⾏更新</span></span>
<span class="line"><span style="color:#FFCB6B;">helm</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">upgrade</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">prometheus</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-n</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">monitoring</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">kube-prometheus-stack</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 更新完成后，在 Prometheus 的 Pod 中检查 etcd 证书是否挂载成功</span></span>
<span class="line"><span style="color:#FFCB6B;">get</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">pod</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-n</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">monitoring</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 进⼊pod，检查</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 进⼊pod</span></span>
<span class="line"><span style="color:#FFCB6B;">kubectl</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">exec</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-it</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">prometheus-prometheus-kube-prometheus-prometheus-0</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-n</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">monitoring</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">--</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">sh</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 查看</span></span>
<span class="line"><span style="color:#FFCB6B;">ls</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">/etc/prometheus/secrets/etcd-certs/</span></span></code></pre></div><h3 id="配置访问地址" tabindex="-1">配置访问地址 <a class="header-anchor" href="#配置访问地址" aria-label="Permalink to &quot;配置访问地址&quot;">​</a></h3><p>因为prometheus重启过，所以之前的9090映射关闭了</p><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#FFCB6B;">kubectl</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">port-forward</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">--address=0.0.0.0</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">svc/prometheus-kube-prometheus-prometheus</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-n</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">monitoring</span><span style="color:#A6ACCD;"> </span><span style="color:#F78C6C;">9090</span><span style="color:#C3E88D;">:9090</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&amp;</span></span>
<span class="line"><span style="color:#FFCB6B;">kubectl</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">port-forward</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">--address=0.0.0.0</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">svc/prometheus-grafana</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-n</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">monitoring</span><span style="color:#A6ACCD;"> </span><span style="color:#F78C6C;">3000</span><span style="color:#C3E88D;">:80</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&amp;</span></span></code></pre></div><h3 id="检查" tabindex="-1">检查 <a class="header-anchor" href="#检查" aria-label="Permalink to &quot;检查&quot;">​</a></h3><p><a href="http://192.168.11.65:9090/targets?search=" target="_blank" rel="noreferrer">http://192.168.11.65:9090/targets?search=</a></p><p><a href="http://192.168.11.65:3000/dashboards" target="_blank" rel="noreferrer">http://192.168.11.65:3000/dashboards</a></p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304261438000.png" alt="image-20230426143806911" style="zoom:80%;"><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304261438891.png" alt="image-20230426143826814" style="zoom:80%;"><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#676E95;font-style:italic;"># 更新配置时报错如下：</span></span>
<span class="line"><span style="color:#FFCB6B;">helm</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">upgrade</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">prometheus</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-n</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">monitoring</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">kube-prometheus-stack</span></span>
<span class="line"></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 解决：删除报错的service</span></span>
<span class="line"><span style="color:#FFCB6B;">kubectl</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">delete</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">svc</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">prometheus-kube-prometheus-kube-etcd</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-n</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">kube-system</span></span></code></pre></div><h1 id="黑盒监控" tabindex="-1">黑盒监控 <a class="header-anchor" href="#黑盒监控" aria-label="Permalink to &quot;黑盒监控&quot;">​</a></h1><h2 id="白盒监控和黑盒监控" tabindex="-1">⽩盒监控和⿊盒监控 <a class="header-anchor" href="#白盒监控和黑盒监控" aria-label="Permalink to &quot;⽩盒监控和⿊盒监控&quot;">​</a></h2><blockquote><p>&quot;⽩盒监控&quot;--需要把对应的Exporter程序安装到被监控的⽬标主机上，从⽽实现对主机各种资源及其状态的数据采集⼯作。但是由于某些情况下操作技术或其他原因，不是所有的Exporter都能部署到被监控的主机环境中，最典型的例⼦是监控全国⽹络质量的稳定性，通常的⽅法是使⽤ping操作，对选取的节点进⾏ICMP测试</p></blockquote><blockquote><p>此时不可能在他⼈应⽤环境中部署相关的Exporter程序。针对这样的应⽤的场景，Prometheus社区提供了⿊盒解决⽅案，Blackbox Exporter⽆须安装在被监控的⽬标环境中，⽤户只需要将其安装在与Prometheus和被监控⽬标互通的环境中，通过HTTP、HTTPS、DNS、TCP、ICMP等⽅式对⽹络进⾏探测监控，还可以探测SSL证书过期时间。</p></blockquote><p>blackbox_exporter:Prometheus 官⽅提供的 exporter 之⼀，可以提供 http、dns、tcp、icmp 的监控数据采集</p><h2 id="二进制安装-二选一" tabindex="-1">二进制安装（⼆选⼀） <a class="header-anchor" href="#二进制安装-二选一" aria-label="Permalink to &quot;二进制安装（⼆选⼀）&quot;">​</a></h2><p><a href="https://prometheus.io/download/" target="_blank" rel="noreferrer">https://prometheus.io/download/</a></p><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#FFCB6B;">wget</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">https://github.com/prometheus/blackbox_exporter/releases/download/v0.23.0/blackbox_exporter-0.23.0.linux-amd64.tar.gztar</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">zxvf</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">blackbox_exporter-0.23.0.linux-amd64.tar.gz</span><span style="color:#A6ACCD;"> </span></span>
<span class="line"></span>
<span class="line"><span style="color:#FFCB6B;">mkdir</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">/opt/prometheus</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-p</span></span>
<span class="line"><span style="color:#FFCB6B;">mv</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">blackbox_exporter-0.23.0.linux-amd64</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">/opt/prometheus/blackbox_exporter</span></span>
<span class="line"></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 创建用户</span></span>
<span class="line"><span style="color:#FFCB6B;">useradd</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-M</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-s</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">/usr/sbin/nologin</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">prometheus</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 更改exporter⽂件夹权限</span></span>
<span class="line"><span style="color:#FFCB6B;">chown</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">prometheus:prometheus</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-R</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">/opt/prometheus</span></span></code></pre></div><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#676E95;font-style:italic;"># 配置开机自启动</span></span>
<span class="line"><span style="color:#FFCB6B;">cat</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&lt;&lt;</span><span style="color:#A6ACCD;">&quot;</span><span style="color:#89DDFF;">EOF</span><span style="color:#A6ACCD;">&quot; </span><span style="color:#89DDFF;">&gt;</span><span style="color:#A6ACCD;">/etc/systemd/system/blackbox_exporter.service</span></span>
<span class="line"><span style="color:#C3E88D;">[Unit]</span></span>
<span class="line"><span style="color:#C3E88D;">Description=blackbox_exporter</span></span>
<span class="line"><span style="color:#C3E88D;">After=network.target</span></span>
<span class="line"></span>
<span class="line"><span style="color:#C3E88D;">[Service]</span></span>
<span class="line"><span style="color:#C3E88D;">Type=simple</span></span>
<span class="line"><span style="color:#C3E88D;">User=prometheus</span></span>
<span class="line"><span style="color:#C3E88D;">Group=prometheus</span></span>
<span class="line"><span style="color:#C3E88D;">ExecStart=/opt/prometheus/blackbox_exporter/blackbox_exporter \</span></span>
<span class="line"><span style="color:#C3E88D;">   --config.file &quot;/opt/prometheus/blackbox_exporter/blackbox.yml&quot; \</span></span>
<span class="line"><span style="color:#C3E88D;">   --web.listen-address &quot;:9115&quot;</span></span>
<span class="line"><span style="color:#C3E88D;">Restart=on-failure</span></span>
<span class="line"></span>
<span class="line"><span style="color:#C3E88D;">[Install]</span></span>
<span class="line"><span style="color:#C3E88D;">WantedBy=multi-user.target</span></span>
<span class="line"><span style="color:#89DDFF;">EOF</span></span></code></pre></div><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#FFCB6B;">systemctl</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">daemon-reload</span></span>
<span class="line"><span style="color:#FFCB6B;">systemctl</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">start</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">blackbox_exporter</span></span>
<span class="line"><span style="color:#FFCB6B;">systemctl</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">enable</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">blackbox_exporter</span></span>
<span class="line"><span style="color:#FFCB6B;">systemctl</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">status</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">blackbox_exporter</span></span>
<span class="line"><span style="color:#FFCB6B;">journalctl</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-u</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">blackbox_exporter</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-f</span></span></code></pre></div><h2 id="docker安装-二选一-⭐" tabindex="-1">Docker安装（二选⼀）⭐ <a class="header-anchor" href="#docker安装-二选一-⭐" aria-label="Permalink to &quot;Docker安装（二选⼀）⭐&quot;">​</a></h2><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#FFCB6B;">mkdir</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">/data/blackbox_exporter/</span></span>
<span class="line"><span style="color:#82AAFF;">cd</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">/data/blackbox_exporter/</span></span></code></pre></div><div class="language-yml"><button title="Copy Code" class="copy"></button><span class="lang">yml</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#F07178;">modules</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#F07178;">http_2xx</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">prober</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">http</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">http</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">method</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">GET</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#F07178;">http_post_2xx</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">prober</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">http</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">http</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">method</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">POST</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#F07178;">tcp_connect</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">prober</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">tcp</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#F07178;">pop3s_banner</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">prober</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">tcp</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">tcp</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">query_response</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">        </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#F07178;">expect</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">^+OK</span><span style="color:#89DDFF;">&quot;</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">tls</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#FF9CAC;">true</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">tls_config</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">        </span><span style="color:#F07178;">insecure_skip_verify</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#FF9CAC;">false</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#F07178;">ssh_banner</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">prober</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">tcp</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">tcp</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">query_response</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">        </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#F07178;">expect</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">^SSH-2.0-</span><span style="color:#89DDFF;">&quot;</span></span>
<span class="line"><span style="color:#A6ACCD;">        </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#F07178;">send</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">SSH-2.0-blackbox-ssh-check</span><span style="color:#89DDFF;">&quot;</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#F07178;">irc_banner</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">prober</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">tcp</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">tcp</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">query_response</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">        </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#F07178;">send</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">NICK prober</span><span style="color:#89DDFF;">&quot;</span></span>
<span class="line"><span style="color:#A6ACCD;">        </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#F07178;">send</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">USER prober prober prober :prober</span><span style="color:#89DDFF;">&quot;</span></span>
<span class="line"><span style="color:#A6ACCD;">        </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#F07178;">expect</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">PING :([^ ]+)</span><span style="color:#89DDFF;">&quot;</span></span>
<span class="line"><span style="color:#A6ACCD;">          </span><span style="color:#F07178;">send</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">PONG ${1}</span><span style="color:#89DDFF;">&quot;</span></span>
<span class="line"><span style="color:#A6ACCD;">        </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#F07178;">expect</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">^:[^ ]+ 001</span><span style="color:#89DDFF;">&quot;</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#F07178;">icmp</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">prober</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">icmp</span></span></code></pre></div><p><strong>docker</strong>直接运⾏</p><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#FFCB6B;">sudo</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">docker</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">run</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-d</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">--restart=always</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">--name</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">blackbox-exporter</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-p</span><span style="color:#A6ACCD;"> </span><span style="color:#F78C6C;">9115</span><span style="color:#C3E88D;">:9115</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-v</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">/data/blackbox_exporter:/etc/blackbox_exporter</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">prom/blackbox-exporter:v0.19.0</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">--config.file=/etc/blackbox_exporter/config.yml</span></span></code></pre></div><p>运行：<a href="http://192.168.88.101:9115/metrics" target="_blank" rel="noreferrer">http://192.168.88.101:9115/metrics</a></p><p><strong>docker-compose</strong>⽅式⭐</p><p>为了⽅便省事，我mongodb⽤的管理员账号，⽣产不建议使⽤</p><div class="language-yml"><button title="Copy Code" class="copy"></button><span class="lang">yml</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#C3E88D;">cd /data/blackbox_exporter/</span></span>
<span class="line"><span style="color:#C3E88D;">cat &gt;docker-compose.yaml &lt;&lt;&quot;EOF&quot;</span></span>
<span class="line"><span style="color:#F07178;">version</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&#39;</span><span style="color:#C3E88D;">3.3</span><span style="color:#89DDFF;">&#39;</span></span>
<span class="line"><span style="color:#F07178;">services</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#F07178;">blackbox_exporter</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">image</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">prom/blackbox-exporter</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">container_name</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">blackbox_exporter</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">restart</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">always</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">volumes</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">/data/blackbox_exporter:/etc/blackbox_exporter</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">ports</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">9115:9115</span></span>
<span class="line"><span style="color:#C3E88D;">EOF</span></span></code></pre></div><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#FFCB6B;">docker-compose</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">up</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-d</span></span>
<span class="line"><span style="color:#FFCB6B;">docker</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">ps</span></span>
<span class="line"><span style="color:#FFCB6B;">docker</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">logs</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-f</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">blackbox_exporter</span></span></code></pre></div><h2 id="prometheus配置-7" tabindex="-1">Prometheus配置 <a class="header-anchor" href="#prometheus配置-7" aria-label="Permalink to &quot;Prometheus配置&quot;">​</a></h2><p>配置prometheus去采集（拉取）blackbox_exporter的监控样本数据</p><div class="language-yml"><button title="Copy Code" class="copy"></button><span class="lang">yml</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#676E95;font-style:italic;">#http配置</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#F07178;">job_name</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">blackbox_http</span><span style="color:#89DDFF;">&quot;</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">metrics_path</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">/probe</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">params</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">module</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">[</span><span style="color:#C3E88D;">http_2xx</span><span style="color:#89DDFF;">]</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">static_configs</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#F07178;">targets</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">        </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">https://www.baidu.com</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">relabel_configs</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#F07178;">source_labels</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">[</span><span style="color:#C3E88D;">__address__</span><span style="color:#89DDFF;">]</span></span>
<span class="line"><span style="color:#A6ACCD;">        </span><span style="color:#F07178;">target_label</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">__param_target</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#F07178;">source_labels</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">[</span><span style="color:#C3E88D;">__param_target</span><span style="color:#89DDFF;">]</span></span>
<span class="line"><span style="color:#A6ACCD;">        </span><span style="color:#F07178;">target_label</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">instance</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#F07178;">target_label</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">__address__</span></span>
<span class="line"><span style="color:#A6ACCD;">        </span><span style="color:#F07178;">replacement</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">192.168.88.101:9115</span></span>
<span class="line"></span>
<span class="line"><span style="color:#676E95;font-style:italic;">#tcp检查配置</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#F07178;">job_name</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">blackbox_tcp</span><span style="color:#89DDFF;">&quot;</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">metrics_path</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">/probe</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">params</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">module</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">[</span><span style="color:#C3E88D;">tcp_connect</span><span style="color:#89DDFF;">]</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">static_configs</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#F07178;">targets</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span></span>
<span class="line"><span style="color:#A6ACCD;">        </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">192.168.88.101:22</span></span>
<span class="line"><span style="color:#A6ACCD;">        </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">192.168.88.101:9090</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">relabel_configs</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#F07178;">source_labels</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">[</span><span style="color:#C3E88D;">__address__</span><span style="color:#89DDFF;">]</span></span>
<span class="line"><span style="color:#A6ACCD;">        </span><span style="color:#F07178;">target_label</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">__param_target</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#F07178;">source_labels</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">[</span><span style="color:#C3E88D;">__param_target</span><span style="color:#89DDFF;">]</span></span>
<span class="line"><span style="color:#A6ACCD;">        </span><span style="color:#F07178;">target_label</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">instance</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#F07178;">target_label</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">__address__</span></span>
<span class="line"><span style="color:#A6ACCD;">        </span><span style="color:#F07178;">replacement</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">192.168.88.101:9115</span></span>
<span class="line"></span>
<span class="line"><span style="color:#676E95;font-style:italic;">#icmp检查配置 ping</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#F07178;">job_name</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">blackbox_icmp</span><span style="color:#89DDFF;">&quot;</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">metrics_path</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">/probe</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">params</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">module</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">[</span><span style="color:#C3E88D;">icmp</span><span style="color:#89DDFF;">]</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">static_configs</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#F07178;">targets</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span></span>
<span class="line"><span style="color:#A6ACCD;">        </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#F78C6C;">192.168.88.101</span></span>
<span class="line"><span style="color:#A6ACCD;">        </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#F78C6C;">192.168.88.101</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">relabel_configs</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#F07178;">source_labels</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">[</span><span style="color:#C3E88D;">__address__</span><span style="color:#89DDFF;">]</span></span>
<span class="line"><span style="color:#A6ACCD;">        </span><span style="color:#F07178;">target_label</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">__param_target</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#F07178;">source_labels</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">[</span><span style="color:#C3E88D;">__param_target</span><span style="color:#89DDFF;">]</span></span>
<span class="line"><span style="color:#A6ACCD;">        </span><span style="color:#F07178;">target_label</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">instance</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#F07178;">target_label</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">__address__</span></span>
<span class="line"><span style="color:#A6ACCD;">        </span><span style="color:#F07178;">replacement</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">192.168.88.101:9115</span></span></code></pre></div><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#676E95;font-style:italic;"># 重新加载配置</span></span>
<span class="line"><span style="color:#FFCB6B;">curl</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-X</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">POST</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">:9090/-/reload</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 检查</span></span>
<span class="line"><span style="color:#FFCB6B;">http://192.168.11.62:9115/probe?target</span><span style="color:#A6ACCD;">=https://www.baidu.com</span><span style="color:#89DDFF;">&amp;</span><span style="color:#A6ACCD;">module</span><span style="color:#89DDFF;">=</span><span style="color:#C3E88D;">http_2xx</span></span>
<span class="line"><span style="color:#FFCB6B;">http://192.168.11.62:9115</span></span>
<span class="line"><span style="color:#FFCB6B;">http://192.168.11.61:9090/targets?search</span><span style="color:#A6ACCD;">=</span></span></code></pre></div><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304262104114.png" alt="image-20230426210408988" style="zoom:80%;"><h2 id="监控项" tabindex="-1">监控项 <a class="header-anchor" href="#监控项" aria-label="Permalink to &quot;监控项&quot;">​</a></h2><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#676E95;font-style:italic;"># 关于探测</span></span>
<span class="line"><span style="color:#FFCB6B;">probe_</span></span>
<span class="line"><span style="color:#FFCB6B;">probe_success</span><span style="color:#A6ACCD;"> </span><span style="color:#676E95;font-style:italic;"># 是否探测成功（取值 1、0 分别表示成功、失败）</span></span>
<span class="line"><span style="color:#FFCB6B;">probe_duration_seconds</span><span style="color:#A6ACCD;"> </span><span style="color:#676E95;font-style:italic;"># 探测的耗时</span></span>
<span class="line"></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 关于 DNS</span></span>
<span class="line"><span style="color:#FFCB6B;">probe_dns_lookup_time_seconds</span><span style="color:#A6ACCD;"> </span><span style="color:#676E95;font-style:italic;"># DNS 解析的耗时</span></span>
<span class="line"><span style="color:#FFCB6B;">probe_ip_protocol</span><span style="color:#A6ACCD;"> </span><span style="color:#676E95;font-style:italic;"># IP 协议，取值为 4、6</span></span>
<span class="line"><span style="color:#FFCB6B;">probe_ip_addr_hash</span><span style="color:#A6ACCD;"> </span><span style="color:#676E95;font-style:italic;"># IP 地址的哈希值，⽤于判断 IP 是否变化</span></span>
<span class="line"></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 关于 HTTP</span></span>
<span class="line"><span style="color:#FFCB6B;">probe_http_status_code</span><span style="color:#A6ACCD;"> </span><span style="color:#676E95;font-style:italic;"># HTTP 响应的状态码。如果发⽣重定向，则取决于最后⼀次响应</span></span>
<span class="line"><span style="color:#FFCB6B;">probe_http_content_length</span><span style="color:#A6ACCD;"> </span><span style="color:#676E95;font-style:italic;"># HTTP 响应的 body ⻓度，单位 bytes</span></span>
<span class="line"><span style="color:#FFCB6B;">probe_http_version</span><span style="color:#A6ACCD;"> </span><span style="color:#676E95;font-style:italic;"># HTTP 响应的协议版本，⽐如 1.1</span></span>
<span class="line"><span style="color:#FFCB6B;">probe_http_ssl</span><span style="color:#A6ACCD;"> </span><span style="color:#676E95;font-style:italic;"># HTTP 响应是否采⽤ SSL ，取值为 1、0</span></span>
<span class="line"><span style="color:#FFCB6B;">probe_ssl_earliest_cert_expiry</span><span style="color:#A6ACCD;"> </span><span style="color:#676E95;font-style:italic;"># SSL 证书的过期时间，为 Unix 时间戳</span></span></code></pre></div><h2 id="触发器配置-5" tabindex="-1">触发器配置 <a class="header-anchor" href="#触发器配置-5" aria-label="Permalink to &quot;触发器配置&quot;">​</a></h2><p>Prometheus配置</p><p># 报警(触发器)配置</p><div class="language-yml"><button title="Copy Code" class="copy"></button><span class="lang">yml</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#F07178;">rule_files</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">alert.yml</span><span style="color:#89DDFF;">&quot;</span><span style="color:#A6ACCD;"> </span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">rules/*.yml</span><span style="color:#89DDFF;">&quot;</span></span></code></pre></div><p>添加blackbox_exporter触发器（告警规则）</p><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#82AAFF;">cd</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">/data/docker-prometheus</span></span></code></pre></div><div class="language-yml"><button title="Copy Code" class="copy"></button><span class="lang">yml</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#F07178;">groups</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#F07178;">name</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">Blackbox</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#F07178;">rules</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#F07178;">alert</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">黑盒子探测失败告警</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">expr</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">probe_success == 0</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">for</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">1m</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">labels</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">severity</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">critical</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">annotations</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">summary</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">黑盒子探测失败{{ $labels.instance }}</span><span style="color:#89DDFF;">&quot;</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">description</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">黑盒子检测失败，当前值：{{ $value }}</span><span style="color:#89DDFF;">&quot;</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#F07178;">alert</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">请求慢告警</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">expr</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">avg_over_time(probe_duration_seconds[1m]) &gt; 1</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">for</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">10m</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">labels</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">severity</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">warning</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">annotations</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">summary</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">请求慢{{ $labels.instance }}</span><span style="color:#89DDFF;">&quot;</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">description</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">请求时间超过1秒，值为：{{ $value }}</span><span style="color:#89DDFF;">&quot;</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#F07178;">alert</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">http状态码检测失败</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">expr</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">probe_http_status_code &lt;= 199 OR probe_http_status_code &gt;= 400</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">for</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">1m</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">labels</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">severity</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">critical</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">annotations</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">summary</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">http状态码检测失败{{ $labels.instance }}</span><span style="color:#89DDFF;">&quot;</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">description</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">HTTP状态码非 200-399，当前状态码为：{{ $value }}</span><span style="color:#89DDFF;">&quot;</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#F07178;">alert</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">ssl证书即将到期</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">expr</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">probe_ssl_earliest_cert_expiry - time() &lt; 86400 * 30</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">for</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">1m</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">labels</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">severity</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">warning</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">annotations</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">summary</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">证书即将到期{{ $labels.instance }}</span><span style="color:#89DDFF;">&quot;</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">description</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">SSL 证书在 30 天后到期，值：{{ $value }}</span><span style="color:#89DDFF;">&quot;</span></span>
<span class="line"></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#F07178;">alert</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">ssl证书即将到期</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">expr</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">probe_ssl_earliest_cert_expiry - time() &lt; 86400 * 3</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">for</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">1m</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">labels</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">severity</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">critical</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">annotations</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">summary</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">证书即将到期{{ $labels.instance }}</span><span style="color:#89DDFF;">&quot;</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">description</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">SSL 证书在 3 天后到期，值：{{ $value }}</span><span style="color:#89DDFF;">&quot;</span></span>
<span class="line"></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#F07178;">alert</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">ssl证书已过期</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">expr</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">probe_ssl_earliest_cert_expiry - time() &lt;= 0</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">for</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">1m</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">labels</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">severity</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">critical</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">annotations</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">summary</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">证书已过期{{ $labels.instance }}</span><span style="color:#89DDFF;">&quot;</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">description</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">SSL 证书已经过期，请确认是否在使用</span><span style="color:#89DDFF;">&quot;</span></span></code></pre></div><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#676E95;font-style:italic;"># 重新加载配置</span></span>
<span class="line"><span style="color:#FFCB6B;">./promtool</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">check</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">rules</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">rules/linux.yml</span></span>
<span class="line"><span style="color:#FFCB6B;">curl</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-X</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">POST</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">:9090/-/reload</span></span>
<span class="line"></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 网站查询</span></span>
<span class="line"><span style="color:#FFCB6B;">http://192.168.11.61:9090/alerts?search</span><span style="color:#A6ACCD;">=</span></span>
<span class="line"><span style="color:#FFCB6B;">http://192.168.11.61:9090/rules</span></span></code></pre></div><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304281504973.png" alt="image-20230428150436866" style="zoom:80%;"><h2 id="dashboard-6" tabindex="-1">Dashboard <a class="header-anchor" href="#dashboard-6" aria-label="Permalink to &quot;Dashboard&quot;">​</a></h2><p>grafana上添加图⾏。图⾏展示⿊盒监控数据</p><p><a href="https://grafana.com/grafana/dashboards/9965" target="_blank" rel="noreferrer">https://grafana.com/grafana/dashboards/9965</a></p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304281506287.png" alt="image-20230428150619152" style="zoom:80%;"><p>问题：检测总耗时这个图⾏，名称显示异常。如下图：</p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304262104253.png" alt="image-20230426210447114" style="zoom:80%;"><p>解决：检测总耗时这个图⾏点编辑---找到 Options --把Legend⾥⾯的值从 _ 修改为</p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304262105769.png" alt="image-20230426210509634" style="zoom:80%;"><p>其他的图⾏也是类似的⽅法</p><h1 id="进程监控" tabindex="-1">进程监控 <a class="header-anchor" href="#进程监控" aria-label="Permalink to &quot;进程监控&quot;">​</a></h1><blockquote><p>如果想要对主机的进程进⾏监控，例如chronyd，sshd等服务进程以及⾃定义脚本程序运⾏状态监控。我们使⽤node exporter就不能实现需求了，此时就需要使⽤process exporter来做进程状态的监控。</p></blockquote><p>项⽬地址：<a href="https://github.com/ncabatoff/process-exporter" target="_blank" rel="noreferrer">https://github.com/ncabatoff/process-exporter</a></p><h2 id="二进制安装-二选一-1" tabindex="-1">二进制安装（⼆选⼀） <a class="header-anchor" href="#二进制安装-二选一-1" aria-label="Permalink to &quot;二进制安装（⼆选⼀）&quot;">​</a></h2><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#FFCB6B;">wget</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">https://github.com/ncabatoff/process-exporter/releases/download/v0.7.10/process-exporter-0.7.10.linux-amd64.tar.gz</span></span>
<span class="line"><span style="color:#FFCB6B;">tar</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-xzvf</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">process-exporter-0.7.10.linux-amd64.tar.gz</span></span>
<span class="line"><span style="color:#FFCB6B;">mkdir</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">/opt/prometheus</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-p</span></span>
<span class="line"><span style="color:#FFCB6B;">mv</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">process-exporter-0.7.10.linux-amd64</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">/opt/prometheus/process_exporter</span></span></code></pre></div><p>创建配置⽂件，监控所有进程</p><div class="language-yml"><button title="Copy Code" class="copy"></button><span class="lang">yml</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#C3E88D;">cat &gt;&gt;/opt/prometheus/process_exporter/process.yml&lt;&lt;&quot;EOF&quot;</span></span>
<span class="line"><span style="color:#F07178;">process_names</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#F07178;">name</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">{{.Comm}}</span><span style="color:#89DDFF;">&quot;</span><span style="color:#A6ACCD;"> </span><span style="color:#676E95;font-style:italic;"># 匹配模板</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">cmdline</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&#39;</span><span style="color:#C3E88D;">.+</span><span style="color:#89DDFF;">&#39;</span><span style="color:#A6ACCD;"> </span><span style="color:#676E95;font-style:italic;"># 匹配名称</span></span>
<span class="line"><span style="color:#C3E88D;">EOF</span></span></code></pre></div><p>创建<strong>systemd</strong></p><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#FFCB6B;">cat</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&lt;&lt;</span><span style="color:#A6ACCD;">&quot;</span><span style="color:#89DDFF;">EOF</span><span style="color:#A6ACCD;">&quot; </span><span style="color:#89DDFF;">&gt;</span><span style="color:#A6ACCD;">/etc/systemd/system/process_exporter.service</span></span>
<span class="line"><span style="color:#C3E88D;">[Unit]</span></span>
<span class="line"><span style="color:#C3E88D;">Description=process_exporter</span></span>
<span class="line"><span style="color:#C3E88D;">After=network.target</span></span>
<span class="line"><span style="color:#C3E88D;">[Service]</span></span>
<span class="line"><span style="color:#C3E88D;">Type=simple</span></span>
<span class="line"><span style="color:#C3E88D;">User=prometheus</span></span>
<span class="line"><span style="color:#C3E88D;">Group=prometheus</span></span>
<span class="line"><span style="color:#C3E88D;">ExecStart=/opt/prometheus/process_exporter/process-exporter -</span></span>
<span class="line"><span style="color:#C3E88D;">config.path=/opt/prometheus/process_exporter/process.yml</span></span>
<span class="line"><span style="color:#C3E88D;">Restart=on-failure</span></span>
<span class="line"><span style="color:#C3E88D;">[Install]</span></span>
<span class="line"><span style="color:#C3E88D;">WantedBy=multi-user.target</span></span>
<span class="line"><span style="color:#89DDFF;">EOF</span></span></code></pre></div><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#676E95;font-style:italic;"># 启动</span></span>
<span class="line"><span style="color:#FFCB6B;">systemctl</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">daemon-reload</span></span>
<span class="line"><span style="color:#FFCB6B;">systemctl</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">start</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">process_exporter</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 加⼊到开机⾃启动</span></span>
<span class="line"><span style="color:#FFCB6B;">systemctl</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">enable</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">process_exporter</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 检查</span></span>
<span class="line"><span style="color:#FFCB6B;">systemctl</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">status</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">process_exporter</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 启动不了检查⽇志</span></span>
<span class="line"><span style="color:#FFCB6B;">journalctl</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-u</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">process_exporter</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-f</span></span></code></pre></div><h2 id="docker安装⭐-3" tabindex="-1">Docker安装⭐ <a class="header-anchor" href="#docker安装⭐-3" aria-label="Permalink to &quot;Docker安装⭐&quot;">​</a></h2><h3 id="创建数据目录" tabindex="-1">创建数据⽬录 <a class="header-anchor" href="#创建数据目录" aria-label="Permalink to &quot;创建数据⽬录&quot;">​</a></h3><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#FFCB6B;">mkdir</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-p</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">/data/process_exporter</span><span style="color:#A6ACCD;"> </span></span>
<span class="line"><span style="color:#82AAFF;">cd</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">/data/process_exporter</span></span></code></pre></div><h3 id="创建配置文件" tabindex="-1">创建配置⽂件 <a class="header-anchor" href="#创建配置文件" aria-label="Permalink to &quot;创建配置⽂件&quot;">​</a></h3><blockquote><p>就在当前目录/data/process_exporter即可</p></blockquote><p>监控所有进程</p><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#FFCB6B;">cat</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&gt;&gt;</span><span style="color:#C3E88D;">process.yml</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&lt;&lt;</span><span style="color:#A6ACCD;">&quot;</span><span style="color:#89DDFF;">EOF</span><span style="color:#A6ACCD;">&quot;</span></span>
<span class="line"><span style="color:#C3E88D;">process_names:</span></span>
<span class="line"><span style="color:#C3E88D;">  - name: &quot;{{.Comm}}&quot; # 匹配模板</span></span>
<span class="line"><span style="color:#C3E88D;">    cmdline:</span></span>
<span class="line"><span style="color:#C3E88D;">    - &#39;.+&#39; # 匹配所有名称，即监控所有进程</span></span>
<span class="line"><span style="color:#89DDFF;">EOF</span></span></code></pre></div><p>监控指定进程</p><div class="language-yml"><button title="Copy Code" class="copy"></button><span class="lang">yml</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#F07178;">process_names</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#F07178;">name</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">{{.Matches}}</span><span style="color:#89DDFF;">&quot;</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">cmdline</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&#39;</span><span style="color:#C3E88D;">nginx</span><span style="color:#89DDFF;">&#39;</span><span style="color:#A6ACCD;"> </span><span style="color:#676E95;font-style:italic;">#唯⼀标识</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#F07178;">name</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">{{.Matches}}</span><span style="color:#89DDFF;">&quot;</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">cmdline</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&#39;</span><span style="color:#C3E88D;">mongod</span><span style="color:#89DDFF;">&#39;</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#F07178;">name</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">{{.Matches}}</span><span style="color:#89DDFF;">&quot;</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">cmdline</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&#39;</span><span style="color:#C3E88D;">mysqld</span><span style="color:#89DDFF;">&#39;</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#F07178;">name</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">{{.Matches}}</span><span style="color:#89DDFF;">&quot;</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">cmdline</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&#39;</span><span style="color:#C3E88D;">redis-server</span><span style="color:#89DDFF;">&#39;</span></span></code></pre></div><h3 id="docker运行" tabindex="-1">Docker运⾏ <a class="header-anchor" href="#docker运行" aria-label="Permalink to &quot;Docker运⾏&quot;">​</a></h3><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#FFCB6B;">docker</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">run</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-d</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">--rm</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-p</span><span style="color:#A6ACCD;"> </span><span style="color:#F78C6C;">9256</span><span style="color:#C3E88D;">:9256</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">--privileged</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-v</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">/proc:/host/proc</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-v</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">`</span><span style="color:#82AAFF;">pwd</span><span style="color:#89DDFF;">`</span><span style="color:#FFCB6B;">:/config</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">--name</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">process-exporter</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">ncabatoff/process-exporter</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">--procfs</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">/host/proc</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-config.path</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">/config/process.yml</span></span></code></pre></div><p>检查：<a href="http://192.168.88.101:9256/metrics" target="_blank" rel="noreferrer">http://192.168.88.101:9256/metrics</a></p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304271413266.png" alt="image-20230427141351001" style="zoom:80%;"><h2 id="prometheus设置-1" tabindex="-1">Prometheus设置 <a class="header-anchor" href="#prometheus设置-1" aria-label="Permalink to &quot;Prometheus设置&quot;">​</a></h2><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#82AAFF;">cd</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">/opt/module/prometheus-2.29.1</span></span></code></pre></div><p>prometheus.yml</p><div class="language-yml"><button title="Copy Code" class="copy"></button><span class="lang">yml</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#F07178;">job_name</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&#39;</span><span style="color:#C3E88D;">process</span><span style="color:#89DDFF;">&#39;</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">scrape_interval</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">30s</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">scrape_timeout</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">15s</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">static_configs</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#F07178;">targets</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">[</span><span style="color:#89DDFF;">&#39;</span><span style="color:#C3E88D;">192.168.88.101:9256</span><span style="color:#89DDFF;">&#39;</span><span style="color:#89DDFF;">]</span></span></code></pre></div><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#676E95;font-style:italic;"># 重新加载配置,检查</span></span>
<span class="line"><span style="color:#FFCB6B;">curl</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-X</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">POST</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">:9090/-/reload</span></span>
<span class="line"><span style="color:#FFCB6B;">http://192.168.11.61:9090/targets?search</span><span style="color:#A6ACCD;">=</span></span></code></pre></div><h2 id="监控指标-1" tabindex="-1">监控指标 <a class="header-anchor" href="#监控指标-1" aria-label="Permalink to &quot;监控指标&quot;">​</a></h2><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#FFCB6B;">namedprocess_</span></span>
<span class="line"><span style="color:#FFCB6B;">namedprocess_namegroup_states</span><span style="color:#A6ACCD;">{state=</span><span style="color:#FFCB6B;">&quot;Zombie&quot;</span><span style="color:#FFCB6B;">}</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">查看僵⼫</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 上下⽂切换数量</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># Counter</span></span>
<span class="line"><span style="color:#FFCB6B;">namedprocess_namegroup_context_switches_total</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># CPU user/system 时间（秒）</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># Counter</span></span>
<span class="line"><span style="color:#FFCB6B;">namedprocess_namegroup_cpu_seconds_total</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 主要⻚缺失次数</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># Counter</span></span>
<span class="line"><span style="color:#FFCB6B;">namedprocess_namegroup_major_page_faults_total</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 次要⻚缺失次数</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># Counter</span></span>
<span class="line"><span style="color:#FFCB6B;">namedprocess_namegroup_minor_page_faults_total</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 内存占⽤（byte）</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># Gauge</span></span>
<span class="line"><span style="color:#FFCB6B;">namedprocess_namegroup_memory_bytes</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 同名进程数量</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># Gauge</span></span>
<span class="line"><span style="color:#FFCB6B;">namedprocess_namegroup_num_procs</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 同名进程状态分布</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># Gauge</span></span>
<span class="line"><span style="color:#FFCB6B;">namedprocess_namegroup_states</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 线程数量</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># Gauge</span></span>
<span class="line"><span style="color:#FFCB6B;">namedprocess_namegroup_num_threads</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 启动时间戳</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># Gauge</span></span>
<span class="line"><span style="color:#FFCB6B;">namedprocess_namegroup_oldest_start_time_seconds</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 打开⽂件描述符数量</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># Gauge</span></span>
<span class="line"><span style="color:#FFCB6B;">namedprocess_namegroup_open_filedesc</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 打开⽂件数 / 允许打开⽂件数</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># Gauge</span></span>
<span class="line"><span style="color:#FFCB6B;">namedprocess_namegroup_worst_fd_ratio</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 读数据量（byte）</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># Counter</span></span>
<span class="line"><span style="color:#FFCB6B;">namedprocess_namegroup_read_bytes_total</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 写数据量（byte）</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># Counter</span></span>
<span class="line"><span style="color:#FFCB6B;">namedprocess_namegroup_write_bytes_total</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 内核wchan等待线程数量</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># Gauge</span></span>
<span class="line"><span style="color:#FFCB6B;">namedprocess_namegroup_threads_wchan</span></span></code></pre></div><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304271416493.png" alt="image-20230427141605237" style="zoom:80%;"><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304271416641.png" alt="image-20230427141617384" style="zoom:80%;"><h2 id="触发器-2" tabindex="-1">触发器 <a class="header-anchor" href="#触发器-2" aria-label="Permalink to &quot;触发器&quot;">​</a></h2><p>prometheus.yml</p><div class="language-yml"><button title="Copy Code" class="copy"></button><span class="lang">yml</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#F07178;">alerting</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#F07178;">alertmanagers</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#F07178;">static_configs</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">        </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#F07178;">targets</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">          </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">localhost:9093</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 报警(触发器)配置</span></span>
<span class="line"><span style="color:#F07178;">rule_files</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">alert.yml</span><span style="color:#89DDFF;">&quot;</span><span style="color:#A6ACCD;"> </span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">rules/*.yml</span><span style="color:#89DDFF;">&quot;</span></span>
<span class="line"><span style="color:#F07178;">scrape_configs</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#F07178;">job_name</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&#39;</span><span style="color:#C3E88D;">alertmanager</span><span style="color:#89DDFF;">&#39;</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">static_configs</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#F07178;">targets</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">[</span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">localhost:9093</span><span style="color:#89DDFF;">&quot;</span><span style="color:#89DDFF;">]</span></span></code></pre></div><p>linux.yml</p><div class="language-yml"><button title="Copy Code" class="copy"></button><span class="lang">yml</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#F07178;">groups</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#F07178;">name</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">process</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#F07178;">rules</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#F07178;">alert</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">进程数多告警</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">expr</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">sum(namedprocess_namegroup_states) by (instance) &gt; 1000</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">for</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">1m</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">labels</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">severity</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">warning</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">annotations</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">summary</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">进程数超过1000</span><span style="color:#89DDFF;">&quot;</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">description</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">服务器当前有{{ $value }}个进程</span><span style="color:#89DDFF;">&quot;</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#F07178;">alert</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">僵尸进程数告警</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">expr</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">sum by(instance, groupname) (namedprocess_namegroup_states{state=&quot;Zombie&quot;}) &gt; 0</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">for</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">1m</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">labels</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">severity</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">warning</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">annotations</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">summary</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">有僵尸进程数</span><span style="color:#89DDFF;">&quot;</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">description</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">进程{{ $labels.groupname }}有{{ $value }}个僵尸进程</span><span style="color:#89DDFF;">&quot;</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#F07178;">alert</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">进程重启告警</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">expr</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">ceil(time() - max by(instance, groupname) (namedprocess_namegroup_oldest_start_time_seconds)) &lt; 60</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">for</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">15s</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">labels</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">severity</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">warning</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">annotations</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">summary</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">进程重启</span><span style="color:#89DDFF;">&quot;</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">description</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">进程{{ $labels.groupname }}在{{ $value }}秒前重启过</span><span style="color:#89DDFF;">&quot;</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#F07178;">alert</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">进程退出告警</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">expr</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">max by(instance, groupname) (delta(namedprocess_namegroup_oldest_start_time_seconds{groupname=~&quot;^java.*|^nginx.*&quot;}[1d])) &lt; 0</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">for</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">1m</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">labels</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">severity</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">warning</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">annotations</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">summary</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">进程退出</span><span style="color:#89DDFF;">&quot;</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">description</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">进程{{ $labels.groupname }}退出了</span><span style="color:#89DDFF;">&quot;</span></span></code></pre></div><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#676E95;font-style:italic;"># 重新加载配置</span></span>
<span class="line"><span style="color:#FFCB6B;">./promtool</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">check</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">rules</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">rules/linux.yml</span></span>
<span class="line"><span style="color:#FFCB6B;">curl</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-X</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">POST</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">:9090/-/reload</span></span></code></pre></div><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304280923377.png" alt="image-20230428092352282" style="zoom:80%;"><h2 id="doshboard-1" tabindex="-1">Doshboard <a class="header-anchor" href="#doshboard-1" aria-label="Permalink to &quot;Doshboard&quot;">​</a></h2><h3 id="显示效果" tabindex="-1">显示效果 <a class="header-anchor" href="#显示效果" aria-label="Permalink to &quot;显示效果&quot;">​</a></h3><p><a href="https://grafana.com/grafana/dashboards/8378-system-processes-metrics/" target="_blank" rel="noreferrer">https://grafana.com/grafana/dashboards/8378-system-processes-metrics/</a></p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304280927109.png" alt="image-20230428092756977" style="zoom:80%;"><h3 id="问题分析" tabindex="-1">问题分析 <a class="header-anchor" href="#问题分析" aria-label="Permalink to &quot;问题分析&quot;">​</a></h3><p>问题下⾯2个图形显示不正常</p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304271419920.png" alt="image-20230427141909658" style="zoom:80%;"><p>process-exporter 升级到 0.5.0后 ,</p><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#FFCB6B;">namedprocess_namegroup_cpu_user_seconds_total</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">和</span></span>
<span class="line"><span style="color:#FFCB6B;">namedprocess_namegroup_cpu_system_seconds_total</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">合为⼀个指标名</span></span>
<span class="line"></span>
<span class="line"><span style="color:#FFCB6B;">namedprocess_namegroup_cpu_seconds_total</span></span>
<span class="line"><span style="color:#FFCB6B;">namedprocess_namegroup_cpu_user_seconds_total变成</span></span>
<span class="line"><span style="color:#FFCB6B;">namedprocess_namegroup_cpu_seconds_total</span><span style="color:#A6ACCD;">{mode=</span><span style="color:#FFCB6B;">&quot;system&quot;</span><span style="color:#FFCB6B;">}</span></span>
<span class="line"><span style="color:#FFCB6B;">namedprocess_namegroup_cpu_system_seconds_total</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">变成</span></span>
<span class="line"><span style="color:#FFCB6B;">namedprocess_namegroup_cpu_seconds_total</span><span style="color:#A6ACCD;">{mode=</span><span style="color:#FFCB6B;">&quot;user&quot;</span><span style="color:#FFCB6B;">}</span></span></code></pre></div><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304271419688.png" alt="image-20230427141931411" style="zoom:50%;"><h3 id="解决方法" tabindex="-1">解决方法 <a class="header-anchor" href="#解决方法" aria-label="Permalink to &quot;解决方法&quot;">​</a></h3><p>Top processes by System CPU cores used图形修改如下：</p><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#FFCB6B;">topk(5,rate(namedprocess_namegroup_cpu_seconds_total</span><span style="color:#A6ACCD;">{mode=</span><span style="color:#FFCB6B;">&quot;system&quot;</span><span style="color:#FFCB6B;">,groupname</span><span style="color:#A6ACCD;">=~</span><span style="color:#FFCB6B;">&quot;</span><span style="color:#A6ACCD;">$processes</span><span style="color:#FFCB6B;">&quot;</span><span style="color:#FFCB6B;">,instance</span><span style="color:#A6ACCD;">=~</span><span style="color:#FFCB6B;">&quot;</span><span style="color:#A6ACCD;">$host</span><span style="color:#FFCB6B;">&quot;</span><span style="color:#FFCB6B;">}[$interval]</span><span style="color:#A6ACCD;">)</span></span>
<span class="line"><span style="color:#FFCB6B;">or</span><span style="color:#A6ACCD;"> </span></span>
<span class="line"><span style="color:#89DDFF;">(</span><span style="color:#FFCB6B;">irate(namedprocess_namegroup_cpu_seconds_total</span><span style="color:#A6ACCD;">{mode=</span><span style="color:#FFCB6B;">&quot;system&quot;</span><span style="color:#FFCB6B;">,groupname</span><span style="color:#A6ACCD;">=~</span><span style="color:#FFCB6B;">&quot;</span><span style="color:#A6ACCD;">$processes</span><span style="color:#FFCB6B;">&quot;</span><span style="color:#FFCB6B;">,instance</span><span style="color:#A6ACCD;">=~</span><span style="color:#FFCB6B;">&quot;</span><span style="color:#A6ACCD;">$host</span><span style="color:#FFCB6B;">&quot;</span><span style="color:#FFCB6B;">}[5m]</span><span style="color:#89DDFF;">)</span><span style="color:#A6ACCD;">))</span></span></code></pre></div><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304280932499.png" alt="image-20230428093211388" style="zoom:80%;"><p>Top processes by Total CPU cores used图形修改如下</p><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#FFCB6B;">topk(5,sum</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">by</span><span style="color:#A6ACCD;"> (groupname,instance) </span><span style="color:#89DDFF;">(</span><span style="color:#FFCB6B;">rate(namedprocess_namegroup_cpu_seconds_total</span><span style="color:#A6ACCD;">{groupname=~</span><span style="color:#FFCB6B;">&quot;</span><span style="color:#A6ACCD;">$processes</span><span style="color:#FFCB6B;">&quot;</span><span style="color:#FFCB6B;">,instance</span><span style="color:#A6ACCD;">=~</span><span style="color:#FFCB6B;">&quot;</span><span style="color:#A6ACCD;">$host</span><span style="color:#FFCB6B;">&quot;</span><span style="color:#FFCB6B;">}[$interval]</span><span style="color:#89DDFF;">)</span><span style="color:#A6ACCD;">)</span></span>
<span class="line"><span style="color:#FFCB6B;">or</span></span>
<span class="line"><span style="color:#FFCB6B;">sum</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">by</span><span style="color:#A6ACCD;"> (groupname,instance) </span><span style="color:#89DDFF;">(</span><span style="color:#FFCB6B;">irate(namedprocess_namegroup_cpu_seconds_total</span><span style="color:#A6ACCD;">{groupname=~</span><span style="color:#FFCB6B;">&quot;</span><span style="color:#A6ACCD;">$processes</span><span style="color:#FFCB6B;">&quot;</span><span style="color:#FFCB6B;">,instance</span><span style="color:#A6ACCD;">=~</span><span style="color:#FFCB6B;">&quot;</span><span style="color:#A6ACCD;">$host</span><span style="color:#FFCB6B;">&quot;</span><span style="color:#FFCB6B;">}[5m]</span><span style="color:#89DDFF;">)</span><span style="color:#A6ACCD;">))</span></span></code></pre></div><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304280931601.png" alt="image-20230428093118493" style="zoom:80%;"><p>或图形改名为 Top processes by User CPU cores used ⽤户进程cpu使⽤率排名</p><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#FFCB6B;">topk(5,rate(namedprocess_namegroup_cpu_seconds_total</span><span style="color:#A6ACCD;">{mode=</span><span style="color:#FFCB6B;">&quot;user&quot;</span><span style="color:#FFCB6B;">,groupname</span><span style="color:#A6ACCD;">=~</span><span style="color:#FFCB6B;">&quot;</span><span style="color:#A6ACCD;">$processes</span><span style="color:#FFCB6B;">&quot;</span><span style="color:#FFCB6B;">,instance</span><span style="color:#A6ACCD;">=~</span><span style="color:#FFCB6B;">&quot;</span><span style="color:#A6ACCD;">$host</span><span style="color:#FFCB6B;">&quot;</span><span style="color:#FFCB6B;">}[$interval]</span><span style="color:#A6ACCD;">)</span></span>
<span class="line"><span style="color:#FFCB6B;">or</span><span style="color:#A6ACCD;"> </span></span>
<span class="line"><span style="color:#89DDFF;">(</span><span style="color:#FFCB6B;">irate(namedprocess_namegroup_cpu_seconds_total</span><span style="color:#A6ACCD;">{mode=</span><span style="color:#FFCB6B;">&quot;user&quot;</span><span style="color:#FFCB6B;">,groupname</span><span style="color:#A6ACCD;">=~</span><span style="color:#FFCB6B;">&quot;</span><span style="color:#A6ACCD;">$processes</span><span style="color:#FFCB6B;">&quot;</span><span style="color:#FFCB6B;">,instance</span><span style="color:#A6ACCD;">=~</span><span style="color:#FFCB6B;">&quot;</span><span style="color:#A6ACCD;">$host</span><span style="color:#FFCB6B;">&quot;</span><span style="color:#FFCB6B;">}[5m]</span><span style="color:#89DDFF;">)</span><span style="color:#A6ACCD;">))</span></span></code></pre></div><p>修改完成后，图⾏正常</p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304271421134.png" alt="image-20230427142112837" style="zoom:80%;"><h1 id="自定义监控" tabindex="-1">自定义监控 <a class="header-anchor" href="#自定义监控" aria-label="Permalink to &quot;自定义监控&quot;">​</a></h1><h2 id="pushgateway-简介" tabindex="-1">Pushgateway 简介 <a class="header-anchor" href="#pushgateway-简介" aria-label="Permalink to &quot;Pushgateway 简介&quot;">​</a></h2><blockquote><p>Pushgateway 是 Prometheus ⽣态中⼀个重要⼯具，使⽤它的原因主要是：Prometheus 采⽤ pull 模式，可能由于不在⼀个⼦⽹或者防⽕墙原因，导致 Prometheus ⽆法直接拉取各个 target 数据。在监控业务数据的时候，需要将不同数据汇总, 由 Prometheus 统⼀收集。当exporter不能满⾜需要时，也可以通过⾃定义（python、shell、java）监控我们想要的数据。</p></blockquote><blockquote><p>由于以上原因，不得不使⽤ pushgateway，但在使⽤之前，有必要了解⼀下它的⼀些弊端：将多个节点数据汇总到 pushgateway, 如果 pushgateway 挂了，受影响⽐多个 target ⼤。Prometheus 拉取状态 up 只针对 pushgateway, ⽆法做到对每个节点有效。Pushgateway 可以持久化推送给它的所有监控数据。因此，即使你的监控已经下线，prometheus 还会拉取到旧的监控数据，需要⼿动清理 pushgateway 不要的数据。</p></blockquote><h2 id="安装配置" tabindex="-1">安装配置 <a class="header-anchor" href="#安装配置" aria-label="Permalink to &quot;安装配置&quot;">​</a></h2><h3 id="二进制安装-6" tabindex="-1">二进制安装 <a class="header-anchor" href="#二进制安装-6" aria-label="Permalink to &quot;二进制安装&quot;">​</a></h3><p>官⽹下载地址<a href="https://prometheus.io/download/" target="_blank" rel="noreferrer">https://prometheus.io/download/</a></p><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#FFCB6B;">wget</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">https://github.com/prometheus/pushgateway/releases/download/v1.5.1/pushgateway-1.5.1.linux-amd64.tar.gz</span></span>
<span class="line"><span style="color:#FFCB6B;">tar</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-xzvf</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">pushgateway-1.5.1.linux-amd64.tar.gz</span></span>
<span class="line"><span style="color:#FFCB6B;">mv</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">pushgateway-1.5.1.linux-amd64</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">/opt/pushgateway</span></span></code></pre></div><p>更改 pushgateway ⽂件夹权限：</p><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#FFCB6B;">chown</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">prometheus:prometheus</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-R</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">/opt/pushgateway</span></span></code></pre></div><p>创建 systemd 服务</p><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#FFCB6B;">cat</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&gt;</span><span style="color:#C3E88D;">/etc/systemd/system/pushgateway.service</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&lt;&lt;</span><span style="color:#A6ACCD;"> &quot;</span><span style="color:#89DDFF;">EOF</span><span style="color:#A6ACCD;">&quot;</span></span>
<span class="line"><span style="color:#C3E88D;">[Unit]</span></span>
<span class="line"><span style="color:#C3E88D;">Description=Prometheus Push Gateway</span></span>
<span class="line"><span style="color:#C3E88D;">After=network.target</span></span>
<span class="line"><span style="color:#C3E88D;">[Service]</span></span>
<span class="line"><span style="color:#C3E88D;">Type=simple</span></span>
<span class="line"><span style="color:#C3E88D;">User=prometheus</span></span>
<span class="line"><span style="color:#C3E88D;">Group=prometheus</span></span>
<span class="line"><span style="color:#C3E88D;">ExecStart=/opt/pushgateway/pushgateway</span></span>
<span class="line"><span style="color:#C3E88D;">[Install]</span></span>
<span class="line"><span style="color:#C3E88D;">WantedBy=multi-user.target</span></span>
<span class="line"><span style="color:#89DDFF;">EOF</span></span></code></pre></div><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#676E95;font-style:italic;"># 启动</span></span>
<span class="line"><span style="color:#FFCB6B;">systemctl</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">daemon-reload</span></span>
<span class="line"><span style="color:#FFCB6B;">systemctl</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">start</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">pushgateway.service</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 加⼊到开机⾃启动</span></span>
<span class="line"><span style="color:#FFCB6B;">systemctl</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">enable</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">pushgateway.service</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 检查</span></span>
<span class="line"><span style="color:#FFCB6B;">systemctl</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">status</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">pushgateway.service</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 检查⽇志</span></span>
<span class="line"><span style="color:#FFCB6B;">journalctl</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-u</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">pushgateway.service</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-f</span></span></code></pre></div><h3 id="docker安装⭐-4" tabindex="-1">Docker安装⭐ <a class="header-anchor" href="#docker安装⭐-4" aria-label="Permalink to &quot;Docker安装⭐&quot;">​</a></h3><p>docker命令⾏运⾏</p><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#FFCB6B;">docker</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">run</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-d</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-p</span><span style="color:#A6ACCD;"> </span><span style="color:#F78C6C;">9091</span><span style="color:#C3E88D;">:9091</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">--restart=always</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">--name</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">pushgateway</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">prom/pushgateway</span></span></code></pre></div><p>docker-compose运⾏</p><div class="language-yml"><button title="Copy Code" class="copy"></button><span class="lang">yml</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#F07178;">version</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&#39;</span><span style="color:#C3E88D;">3.3</span><span style="color:#89DDFF;">&#39;</span></span>
<span class="line"><span style="color:#F07178;">services</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#F07178;">pushgateway</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">image</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">prom/pushgateway</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">container_name</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">pushgateway</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">restart</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">always</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">expose</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#F78C6C;">9091</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">ports</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">9091:9091</span><span style="color:#89DDFF;">&quot;</span></span></code></pre></div><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#676E95;font-style:italic;"># 启动检查</span></span>
<span class="line"><span style="color:#FFCB6B;">docker-compose</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">up</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-d</span></span>
<span class="line"><span style="color:#FFCB6B;">docker</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">ps</span></span></code></pre></div><h3 id="prometheus配置-8" tabindex="-1">Prometheus配置 <a class="header-anchor" href="#prometheus配置-8" aria-label="Permalink to &quot;Prometheus配置&quot;">​</a></h3><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#676E95;font-style:italic;"># 去pull拉取pushgateway收集到的数据</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 进⼊到prometheus安装⽬录</span></span>
<span class="line"><span style="color:#82AAFF;">cd</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">/opt/module/prometheus-2.29.1</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 通过cat在prometheus.yml⽂件末尾添加</span></span></code></pre></div><div class="language-yml"><button title="Copy Code" class="copy"></button><span class="lang">yml</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#F07178;">job_name</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">pushgateway</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">honor_labels</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#FF9CAC;">true</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#F07178;">static_configs</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#F07178;">targets</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">[</span><span style="color:#89DDFF;">&#39;</span><span style="color:#C3E88D;">192.168.88.101:9091</span><span style="color:#89DDFF;">&#39;</span><span style="color:#89DDFF;">]</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#F07178;">labels</span><span style="color:#89DDFF;">:</span></span>
<span class="line"><span style="color:#A6ACCD;">        </span><span style="color:#F07178;">instance</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">pushgateway</span></span></code></pre></div><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#676E95;font-style:italic;"># 重载配置</span></span>
<span class="line"><span style="color:#FFCB6B;">curl</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-X</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">POST</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">:9090/-/reload</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 检查</span></span>
<span class="line"><span style="color:#FFCB6B;">http://192.168.11.61:9090/targets?search</span><span style="color:#A6ACCD;">=</span></span></code></pre></div><h2 id="推送监控数据" tabindex="-1">推送监控数据 <a class="header-anchor" href="#推送监控数据" aria-label="Permalink to &quot;推送监控数据&quot;">​</a></h2><h3 id="使用curl" tabindex="-1">使⽤curl <a class="header-anchor" href="#使用curl" aria-label="Permalink to &quot;使⽤curl&quot;">​</a></h3><blockquote><p>正常情况我们会使⽤ Client SDK 推送数据到 pushgateway, 但是我们还可以curl调⽤ API 来管理, 例如：向 {job=&quot;some_job&quot;} 添加单条数据：</p></blockquote><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#82AAFF;">echo</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">some_metric 3.14</span><span style="color:#89DDFF;">&quot;</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">|</span><span style="color:#A6ACCD;"> </span><span style="color:#FFCB6B;">curl</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">--data-binary</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">@-</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">http://192.168.88.101:9091/metrics/job/hello</span></span>
<span class="line"><span style="color:#82AAFF;">echo</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">some_metric 3.14</span><span style="color:#89DDFF;">&quot;</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">|</span><span style="color:#A6ACCD;"> </span><span style="color:#FFCB6B;">curl</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">--data-binary</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">@-</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">http://192.168.88.101:9091/metrics/job/hello</span></span></code></pre></div><p>添加更多更复杂数据，通常数据会带上 instance（some_instance为instance名）, 表示来源位置：</p><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#FFCB6B;">cat</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&lt;&lt;</span><span style="color:#89DDFF;">EOF</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">|</span><span style="color:#A6ACCD;"> curl --data-binary @- http://192.168.88.101:9091/metrics/job/some_job/instance/some_instance</span></span>
<span class="line"><span style="color:#C3E88D;">some_metric{label=&quot;val1&quot;} 42</span></span>
<span class="line"><span style="color:#C3E88D;">another_metric 2398.283</span></span>
<span class="line"><span style="color:#89DDFF;">EOF</span></span></code></pre></div><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#676E95;font-style:italic;"># 删除某个组下的某实例的所有数据：</span></span>
<span class="line"><span style="color:#FFCB6B;">curl</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-X</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">DELETE</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">http://192.168.88.101:9091/metrics/job/some_job/instance/some_instance</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 删除某个组下的所有数据</span></span>
<span class="line"><span style="color:#FFCB6B;">curl</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-X</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">DELETE</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">http://192.168.88.101:9091/metrics/job/some_job</span></span></code></pre></div><p><a href="http://192.168.88.101:9090/graph" target="_blank" rel="noreferrer">http://192.168.88.101:9090/graph</a></p><p><a href="http://192.168.88.101:9091/metrics" target="_blank" rel="noreferrer">http://192.168.88.101:9091/metrics</a></p><blockquote><p>刚刚传上来的两条数据</p></blockquote><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304302224684.png" alt="image-20230430222437575" style="zoom:80%;"><h3 id="使用python" tabindex="-1">使⽤python <a class="header-anchor" href="#使用python" aria-label="Permalink to &quot;使⽤python&quot;">​</a></h3><p>文档：<a href="https://github.com/prometheus/client_python#exporting-to-a-pushgateway" target="_blank" rel="noreferrer">https://github.com/prometheus/client_python#exporting-to-a-pushgateway</a></p><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#676E95;font-style:italic;"># 安装prometheus_client模块</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 安装pip</span></span>
<span class="line"><span style="color:#FFCB6B;">yum</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">install</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">python3-pip</span></span>
<span class="line"><span style="color:#FFCB6B;">apt</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">install</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">python3-pip</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 通过pip安装prometheus_client</span></span>
<span class="line"><span style="color:#FFCB6B;">pip3</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">install</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">prometheus_client</span></span></code></pre></div><div class="language-python"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#A6ACCD;">cat </span><span style="color:#89DDFF;">&gt;</span><span style="color:#A6ACCD;">p1</span><span style="color:#89DDFF;">.</span><span style="color:#F07178;">py</span><span style="color:#89DDFF;">&lt;&lt;</span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">EOF</span><span style="color:#89DDFF;">&quot;</span></span>
<span class="line"><span style="color:#89DDFF;font-style:italic;">from</span><span style="color:#A6ACCD;"> prometheus_client </span><span style="color:#89DDFF;font-style:italic;">import</span><span style="color:#A6ACCD;"> CollectorRegistry</span><span style="color:#89DDFF;">,</span><span style="color:#A6ACCD;"> Gauge</span><span style="color:#89DDFF;">,</span><span style="color:#A6ACCD;"> push_to_gateway</span></span>
<span class="line"><span style="color:#A6ACCD;">registry </span><span style="color:#89DDFF;">=</span><span style="color:#A6ACCD;"> </span><span style="color:#82AAFF;">CollectorRegistry</span><span style="color:#89DDFF;">()</span></span>
<span class="line"><span style="color:#A6ACCD;">g </span><span style="color:#89DDFF;">=</span><span style="color:#A6ACCD;"> </span><span style="color:#82AAFF;">Gauge</span><span style="color:#89DDFF;">(</span><span style="color:#89DDFF;">&#39;</span><span style="color:#C3E88D;">job_last_success_unixtime</span><span style="color:#89DDFF;">&#39;</span><span style="color:#89DDFF;">,</span><span style="color:#82AAFF;"> </span><span style="color:#89DDFF;">&#39;</span><span style="color:#C3E88D;">Last time a batch job successfully finished</span><span style="color:#89DDFF;">&#39;</span><span style="color:#89DDFF;">,</span><span style="color:#A6ACCD;font-style:italic;">registry</span><span style="color:#89DDFF;">=</span><span style="color:#82AAFF;">registry</span><span style="color:#89DDFF;">)</span></span>
<span class="line"><span style="color:#A6ACCD;">g</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">set_to_current_time</span><span style="color:#89DDFF;">()</span></span>
<span class="line"><span style="color:#82AAFF;">push_to_gateway</span><span style="color:#89DDFF;">(</span><span style="color:#89DDFF;">&#39;</span><span style="color:#C3E88D;">localhost:9091</span><span style="color:#89DDFF;">&#39;</span><span style="color:#89DDFF;">,</span><span style="color:#82AAFF;"> </span><span style="color:#A6ACCD;font-style:italic;">job</span><span style="color:#89DDFF;">=</span><span style="color:#89DDFF;">&#39;</span><span style="color:#C3E88D;">batchA</span><span style="color:#89DDFF;">&#39;</span><span style="color:#89DDFF;">,</span><span style="color:#82AAFF;"> </span><span style="color:#A6ACCD;font-style:italic;">registry</span><span style="color:#89DDFF;">=</span><span style="color:#82AAFF;">registry</span><span style="color:#89DDFF;">)</span></span>
<span class="line"><span style="color:#A6ACCD;">EOF</span></span></code></pre></div><div class="language-"><button title="Copy Code" class="copy"></button><span class="lang"></span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#A6ACCD;">python3 p1.py</span></span></code></pre></div><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304302229843.png" alt="image-20230430222901732" style="zoom:80%;"><h2 id="监控data数据目录下的文件数量-需求" tabindex="-1">监控data数据⽬录下的⽂件数量（需求） <a class="header-anchor" href="#监控data数据目录下的文件数量-需求" aria-label="Permalink to &quot;监控data数据⽬录下的⽂件数量（需求）&quot;">​</a></h2><h3 id="shell脚本" tabindex="-1"><strong>shell</strong>脚本 <a class="header-anchor" href="#shell脚本" aria-label="Permalink to &quot;**shell**脚本&quot;">​</a></h3><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#FFCB6B;">cat</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&gt;</span><span style="color:#C3E88D;">/opt/file_num.sh</span><span style="color:#89DDFF;">&lt;&lt;</span><span style="color:#A6ACCD;">&quot;</span><span style="color:#89DDFF;">EOF</span><span style="color:#A6ACCD;">&quot;</span></span>
<span class="line"><span style="color:#C3E88D;">#!/bin/sh</span></span>
<span class="line"><span style="color:#C3E88D;">FILENUM=`ls -l /data |sed 1d| wc -l`</span></span>
<span class="line"><span style="color:#C3E88D;">echo &quot;data_file_num ${FILENUM}&quot; | curl --data-binary @- http://192.168.88.101:9091/metrics/job/test_job/instance/test</span></span>
<span class="line"><span style="color:#89DDFF;">EOF</span></span></code></pre></div><h3 id="定时任务" tabindex="-1">定时任务 <a class="header-anchor" href="#定时任务" aria-label="Permalink to &quot;定时任务&quot;">​</a></h3><p>直接复制到定时任务文件即可</p><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#FFCB6B;">crontab</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-e</span></span>
<span class="line"><span style="color:#89DDFF;">*</span><span style="color:#A6ACCD;">/1 </span><span style="color:#89DDFF;">*</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">*</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">*</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">*</span><span style="color:#A6ACCD;"> /bin/sh /opt/file_num.sh </span><span style="color:#89DDFF;">&gt;</span><span style="color:#A6ACCD;">/dev/null </span><span style="color:#89DDFF;">2&gt;&amp;1</span></span></code></pre></div><h3 id="python脚本" tabindex="-1"><strong>python</strong>脚本 <a class="header-anchor" href="#python脚本" aria-label="Permalink to &quot;**python**脚本&quot;">​</a></h3><div class="language-python"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#A6ACCD;">cat </span><span style="color:#89DDFF;">&gt;/</span><span style="color:#A6ACCD;">opt</span><span style="color:#89DDFF;">/</span><span style="color:#A6ACCD;">file_num</span><span style="color:#89DDFF;">.</span><span style="color:#F07178;">py</span><span style="color:#89DDFF;">&lt;&lt;</span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">EOF</span><span style="color:#89DDFF;">&quot;</span></span>
<span class="line"><span style="color:#89DDFF;font-style:italic;">from</span><span style="color:#A6ACCD;"> prometheus_client </span><span style="color:#89DDFF;font-style:italic;">import</span><span style="color:#A6ACCD;"> CollectorRegistry</span><span style="color:#89DDFF;">,</span><span style="color:#A6ACCD;"> Gauge</span><span style="color:#89DDFF;">,</span><span style="color:#A6ACCD;"> push_to_gateway</span></span>
<span class="line"><span style="color:#89DDFF;font-style:italic;">import</span><span style="color:#A6ACCD;"> os</span></span>
<span class="line"><span style="color:#A6ACCD;">path </span><span style="color:#89DDFF;">=</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&#39;</span><span style="color:#C3E88D;">/data</span><span style="color:#89DDFF;">&#39;</span><span style="color:#A6ACCD;"> </span><span style="color:#676E95;font-style:italic;"># 输⼊⽂件夹地址</span></span>
<span class="line"><span style="color:#A6ACCD;">files </span><span style="color:#89DDFF;">=</span><span style="color:#A6ACCD;"> os</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">listdir</span><span style="color:#89DDFF;">(</span><span style="color:#82AAFF;">path</span><span style="color:#89DDFF;">)</span><span style="color:#A6ACCD;"> </span><span style="color:#676E95;font-style:italic;"># 读⼊⽂件夹</span></span>
<span class="line"><span style="color:#A6ACCD;">num_png </span><span style="color:#89DDFF;">=</span><span style="color:#A6ACCD;"> </span><span style="color:#82AAFF;">len</span><span style="color:#89DDFF;">(</span><span style="color:#82AAFF;">files</span><span style="color:#89DDFF;">)</span><span style="color:#A6ACCD;"> </span><span style="color:#676E95;font-style:italic;"># 统计⽂件夹中的⽂件个数</span></span>
<span class="line"><span style="color:#A6ACCD;">registry </span><span style="color:#89DDFF;">=</span><span style="color:#A6ACCD;"> </span><span style="color:#82AAFF;">CollectorRegistry</span><span style="color:#89DDFF;">()</span></span>
<span class="line"><span style="color:#A6ACCD;">g </span><span style="color:#89DDFF;">=</span><span style="color:#A6ACCD;"> </span><span style="color:#82AAFF;">Gauge</span><span style="color:#89DDFF;">(</span><span style="color:#89DDFF;">&#39;</span><span style="color:#C3E88D;">python_data_file_num</span><span style="color:#89DDFF;">&#39;</span><span style="color:#89DDFF;">,</span><span style="color:#82AAFF;"> </span><span style="color:#89DDFF;">&#39;</span><span style="color:#C3E88D;">data file num</span><span style="color:#89DDFF;">&#39;</span><span style="color:#89DDFF;">,</span><span style="color:#82AAFF;"> </span><span style="color:#89DDFF;">[</span><span style="color:#89DDFF;">&#39;</span><span style="color:#C3E88D;">instance</span><span style="color:#89DDFF;">&#39;</span><span style="color:#89DDFF;">],</span><span style="color:#A6ACCD;font-style:italic;">registry</span><span style="color:#89DDFF;">=</span><span style="color:#82AAFF;">registry</span><span style="color:#89DDFF;">)</span></span>
<span class="line"></span>
<span class="line"><span style="color:#A6ACCD;">g</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">labels</span><span style="color:#89DDFF;">(</span><span style="color:#89DDFF;">&#39;</span><span style="color:#C3E88D;">test</span><span style="color:#89DDFF;">&#39;</span><span style="color:#89DDFF;">).</span><span style="color:#82AAFF;">set</span><span style="color:#89DDFF;">(</span><span style="color:#82AAFF;">num_png</span><span style="color:#89DDFF;">)</span></span>
<span class="line"><span style="color:#82AAFF;">push_to_gateway</span><span style="color:#89DDFF;">(</span><span style="color:#89DDFF;">&#39;</span><span style="color:#C3E88D;">192.168.88.101:9091</span><span style="color:#89DDFF;">&#39;</span><span style="color:#89DDFF;">,</span><span style="color:#82AAFF;"> </span><span style="color:#A6ACCD;font-style:italic;">job</span><span style="color:#89DDFF;">=</span><span style="color:#89DDFF;">&#39;</span><span style="color:#C3E88D;">test_job</span><span style="color:#89DDFF;">&#39;</span><span style="color:#89DDFF;">,</span><span style="color:#82AAFF;"> </span><span style="color:#A6ACCD;font-style:italic;">registry</span><span style="color:#89DDFF;">=</span><span style="color:#82AAFF;">registry</span><span style="color:#89DDFF;">)</span></span>
<span class="line"><span style="color:#A6ACCD;">EOF</span></span></code></pre></div><h3 id="eof定时任务" tabindex="-1">EOF定时任务 <a class="header-anchor" href="#eof定时任务" aria-label="Permalink to &quot;EOF定时任务&quot;">​</a></h3><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#FFCB6B;">crontab</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-e</span></span>
<span class="line"><span style="color:#89DDFF;">*</span><span style="color:#A6ACCD;">/1 </span><span style="color:#89DDFF;">*</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">*</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">*</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">*</span><span style="color:#A6ACCD;"> /usr/bin/python3 /opt/file_num.py </span><span style="color:#89DDFF;">&gt;</span><span style="color:#A6ACCD;">/dev/null </span><span style="color:#89DDFF;">2&gt;&amp;1</span></span></code></pre></div><h3 id="配置告警规则-1" tabindex="-1">配置告警规则 <a class="header-anchor" href="#配置告警规则-1" aria-label="Permalink to &quot;配置告警规则&quot;">​</a></h3><p>例如：当data⽬录下的⽂件数量超过5，报警出来</p><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#FFCB6B;">groups:</span></span>
<span class="line"><span style="color:#FFCB6B;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">name:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">pushgateway</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#FFCB6B;">rules:</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#FFCB6B;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">alert:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">DataFileNum</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#FFCB6B;">expr:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">data_file_num</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&gt;</span><span style="color:#A6ACCD;"> </span><span style="color:#F78C6C;">5</span></span>
<span class="line"><span style="color:#A6ACCD;">    for: 0m</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#FFCB6B;">labels:</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#FFCB6B;">severity:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">warning</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#FFCB6B;">annotations:</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#FFCB6B;">summary:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&#39;</span><span style="color:#C3E88D;">data数据⽬录⽂件数过多</span><span style="color:#89DDFF;">&#39;</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#FFCB6B;">description:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">data数据⽬录⽂件数&gt;5,当前数量:{{ </span><span style="color:#A6ACCD;">$value</span><span style="color:#C3E88D;"> }}</span><span style="color:#89DDFF;">&quot;</span></span></code></pre></div><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#676E95;font-style:italic;"># 重载配置</span></span>
<span class="line"><span style="color:#FFCB6B;">curl</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-X</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">POST</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">:9090/-/reload</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 检查</span></span>
<span class="line"><span style="color:#FFCB6B;">http://192.168.11.61:9090/alerts?search</span><span style="color:#A6ACCD;">=</span></span></code></pre></div><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304302237120.png" alt="image-20230430223747010" style="zoom:67%;"><h2 id="grafana添加图形" tabindex="-1">grafana添加图形 <a class="header-anchor" href="#grafana添加图形" aria-label="Permalink to &quot;grafana添加图形&quot;">​</a></h2><p>当然上⾯只是个举例：,你也可以监控任何你想要监控的数据</p><h1 id="监控综述" tabindex="-1">监控综述 <a class="header-anchor" href="#监控综述" aria-label="Permalink to &quot;监控综述&quot;">​</a></h1><h2 id="监控流程" tabindex="-1">监控流程 <a class="header-anchor" href="#监控流程" aria-label="Permalink to &quot;监控流程&quot;">​</a></h2><blockquote><p>1、需要在被监控的服务器上安装xx_exporter来收集数据</p><p>2、添加Prometheus配置，去收集（xx_exporter）提供的监控样本数据</p><p>3、配置触发器（告警规则）</p><p>4、Grafana添加dashboard，图形的展示</p></blockquote><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304271118201.png" alt="image-20230427111852963" style="zoom:80%;"><blockquote><p>注：因为prometheus要去exporter去拉取（pull）数据，所以安装exporter的服务器防⽕墙要开放对应的端⼝给prometheus服务器⿊盒监控和⽩盒监控</p></blockquote><h2 id="exporter" tabindex="-1">exporter <a class="header-anchor" href="#exporter" aria-label="Permalink to &quot;exporter&quot;">​</a></h2><p><a href="https://prometheus.io/docs/instrumenting/exporters/" target="_blank" rel="noreferrer">https://prometheus.io/docs/instrumenting/exporters/</a></p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304271404899.png" alt="image-20230427140457631" style="zoom:80%;"><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304271405264.png" alt="image-20230427140513015" style="zoom:80%;"><h1 id="运维监控工具" tabindex="-1">运维监控工具 <a class="header-anchor" href="#运维监控工具" aria-label="Permalink to &quot;运维监控工具&quot;">​</a></h1><p><a href="https://github.com/tianshiyeben/wgcloud/blob/master/README_cn.md" target="_blank" rel="noreferrer">https://github.com/tianshiyeben/wgcloud/blob/master/README_cn.md</a></p><blockquote><p>给大家介绍一款Linux运维监控工具 ——wgcloud，功能非常强大，完全开源！wgcloud支持显示CPU利用率、CPU温度、内存利用率、磁盘容量、磁盘IO、硬盘智能健康状态、系统负载、连接数、网卡流量、硬件系统信息等。支持进程应用、文件、端口、服务器上的日志、docker容器、数据库、数据表等资源。</p></blockquote><blockquote><p>支持监控服务接口API、数据通讯设备（如交换机、路由器、打印机等）自动生成网络拓扑图、大屏可视化、web SSH（堡垒机）、统计分析图表、命令下发、批量执行、告警信息推送（如邮箱、钉钉、微信、短信等）</p></blockquote><h3 id="演示截图" tabindex="-1">演示截图 <a class="header-anchor" href="#演示截图" aria-label="Permalink to &quot;演示截图&quot;">​</a></h3><p><img src="https://mmbiz.qpic.cn/mmbiz_png/JfTPiahTHJhpYAHmxLWodw8K9fbib3AKYhnSDCfkuBcatLQRF2uHQZ7hic2v8BZbv7eU0LScd6wSztMIAf5EslIiag/640?wx_fmt=png&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" alt="图片"></p><p><img src="https://mmbiz.qpic.cn/mmbiz_png/JfTPiahTHJhpYAHmxLWodw8K9fbib3AKYh8kEibq6QCStZSlQ2qsicVEQuO0VtS1W8Wu4FptxdaIDxz75tF7k5YXRQ/640?wx_fmt=png&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" alt="图片"></p><p><img src="https://mmbiz.qpic.cn/mmbiz_png/JfTPiahTHJhpYAHmxLWodw8K9fbib3AKYh16lKOyEuicEnOILSeBVJ2pTXFiaPd1bd8ZiaAekAFq4LCibzAxddLQx09g/640?wx_fmt=png&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" alt="图片"></p><p><img src="https://mmbiz.qpic.cn/mmbiz_png/JfTPiahTHJhpYAHmxLWodw8K9fbib3AKYhwdYq5TsqTAZDmmzjOP2ibHM2BNRkAM7KoXYcvzuGN1I2IfPn67ibiaVXQ/640?wx_fmt=png&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" alt="图片"></p><p><img src="https://mmbiz.qpic.cn/mmbiz_png/JfTPiahTHJhpYAHmxLWodw8K9fbib3AKYhdB40bvQibpvm6Tfia5XkxMFqhlVmzwb2zhC8hK6EsATRNsWa0TCexLpQ/640?wx_fmt=png&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" alt="图片"></p><p><img src="https://mmbiz.qpic.cn/mmbiz_png/JfTPiahTHJhpYAHmxLWodw8K9fbib3AKYhyHzB0UicuER1DzFA9LYyLYCL11ZnRGk6t1pQb2OhI6Cu6I3OaX7cE8w/640?wx_fmt=png&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" alt="图片"></p><p><img src="https://mmbiz.qpic.cn/mmbiz_png/JfTPiahTHJhpYAHmxLWodw8K9fbib3AKYhPYbqbmJ8JezXRL9xqXRZKeSIGWMqZn2yQriaaoKBlauFKhic16QRwX5w/640?wx_fmt=png&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" alt="图片"></p><p><img src="https://mmbiz.qpic.cn/mmbiz_png/JfTPiahTHJhpYAHmxLWodw8K9fbib3AKYhibASbTjEQtqfV0AIwA3JJhkf656BXEBMiaWq7Q6AjdPlGJonnTKDOyKQ/640?wx_fmt=png&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" alt="图片"></p><p><img src="https://mmbiz.qpic.cn/mmbiz_png/JfTPiahTHJhpYAHmxLWodw8K9fbib3AKYhs9zPN52hj9Y38a2KAevuTVx41e8tm4gYmSGkjcMk4r8piaibAHiaiak2WQ/640?wx_fmt=png&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" alt="图片"></p><p><img src="https://mmbiz.qpic.cn/mmbiz_png/JfTPiahTHJhpYAHmxLWodw8K9fbib3AKYhibV41ybvIBmygsh0uudqjyYxaZTjIAqic7icbIElia5fRFDeJibw6k6612w/640?wx_fmt=png&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" alt="图片"></p><h3 id="支持操作系统平台" tabindex="-1">支持操作系统平台 <a class="header-anchor" href="#支持操作系统平台" aria-label="Permalink to &quot;支持操作系统平台&quot;">​</a></h3><p>支持监控linux系列：Debian、RedHat、CentOS、Ubuntu .....</p><p>支持监控windows系列：Windows Server 2008 R2 2012 , 2016 , 2019, Windows 7, Windows 8, windows 10 ,windows 11</p><p>支持监控UNIX系列：Solaris、FreeBSD、OpenBSD……</p><p>支持监控Mac OS系列：Mac OS AMD64</p><blockquote><p>开源地址：<a href="https://github.com/tianshiyeben/wgcloud" target="_blank" rel="noreferrer">https://github.com/tianshiyeben/wgcloud</a></p></blockquote></div></div></main><footer class="VPDocFooter" data-v-6b87e69f data-v-37656e44><!--[--><!--]--><!----><nav class="prev-next" data-v-37656e44><div class="pager" data-v-37656e44><a class="pager-link prev" href="/notebook/%E5%8F%AF%E8%A7%86%E5%8C%96%20&amp;%20%E7%9B%91%E6%8E%A7/%E7%9B%91%E6%8E%A7%E5%9F%BA%E7%A1%80.html" data-v-37656e44><span class="desc" data-v-37656e44>Previous page</span><span class="title" data-v-37656e44>监控基础</span></a></div><div class="pager" data-v-37656e44><a class="pager-link next" href="/notebook/%E5%8F%AF%E8%A7%86%E5%8C%96%20&amp;%20%E7%9B%91%E6%8E%A7/%E5%8F%AF%E8%A7%86%E5%8C%96%E5%A4%A7%E5%B1%8F.html" data-v-37656e44><span class="desc" data-v-37656e44>Next page</span><span class="title" data-v-37656e44>可视化大屏</span></a></div></nav></footer><!--[--><!--]--></div></div></div><!--[--><!--]--></div></div><!----><!--[--><!--]--></div></div>
    <script>window.__VP_HASH_MAP__=JSON.parse("{\"2、数据库_mysql_mysql面试_基础.md\":\"40da680a\",\"1、学前端_5、小程序_小程序项目.md\":\"60a1629b\",\"1、学前端_4、node_知识篇.md\":\"a7fb500e\",\"1、学前端_2、js_ts_es6 进阶.md\":\"6d07ba10\",\"1、学前端_3、vue_vue3_vue3进阶.md\":\"7ac622b4\",\"5、运维_jenkins.md\":\"929081f8\",\"1、学前端_2、js_ts_typescript.md\":\"875a4aa4\",\"2、数据库_mysql_mysql核心_设计.md\":\"7faf46d1\",\"2、数据库_mysql_mysql核心_基础.md\":\"d8e97f3e\",\"1、学前端_1、html_css_html基础.md\":\"7584d076\",\"1、学前端_5、专题篇_问题篇.md\":\"e893aaa2\",\"2、数据库_mysql_mysql面试_进阶.md\":\"f934806d\",\"3、springboot_运维_原理.md\":\"f4a39db6\",\"2、数据库_influxdb.md\":\"6e1711e1\",\"3、springboot_新特性.md\":\"cdf3e307\",\"mybatis_mybatisplus_jpa.md\":\"8e41681b\",\"1、学前端_5、小程序_小程序优化.md\":\"a2185198\",\"2、数据库_redis_redis基础.md\":\"856df0e0\",\"linux_实用脚本.md\":\"f2299dd5\",\"4、微服务_必备_分布式基础.md\":\"d49863d5\",\"2、数据库_redis_redis优化.md\":\"e66ae32f\",\"4、微服务_springsecurity_进阶篇.md\":\"235a8e9e\",\"5、运维_chatgpt.md\":\"10db3823\",\"2、数据库_mysql_分库分表.md\":\"e1c8a095\",\"start.md\":\"9bc1ff8d\",\"5、运维_github.md\":\"2ec6c735\",\"java学前端_css.md\":\"f11b47f0\",\"1、学前端_5、专题篇_知识篇.md\":\"a463ed8d\",\"linux_软件部署.md\":\"d6722925\",\"2、数据库_neo4j.md\":\"97ad22ac\",\"team.md\":\"ce467a6a\",\"nginx_实战篇.md\":\"7785486e\",\"index.md\":\"8c3ec167\",\"计算机基础_计算机网络_网络基础.md\":\"7a54a85d\",\"1、学前端_4、node_进阶篇.md\":\"60f6db69\",\"java_java集合.md\":\"a049b313\",\"1、学前端_3、vue_vue3_vue3高级.md\":\"614d1516\",\"1、学前端_5、小程序_微信小程序.md\":\"9a4be771\",\"5、运维_netty.md\":\"12ca0278\",\"2、数据库_mysql_mysql核心_运维.md\":\"83f97c16\",\"idea_vs code.md\":\"afdcb593\",\"java学前端_vue3_组件.md\":\"1086884e\",\"idea_chrome.md\":\"4a32afbc\",\"云原生_k8s.md\":\"db58e65a\",\"2、数据库_mysql_mysql核心_进阶.md\":\"61d16dff\",\"ssm_springbatch.md\":\"f799ab4a\",\"三高_分布式.md\":\"db1b8a1b\",\"2、数据库_elasticsearch_1、es基础.md\":\"04d17448\",\"linux_linux基础.md\":\"4b0bf394\",\"idea_idea插件.md\":\"fa86e45a\",\"可视化 _ 监控_可视化大屏.md\":\"004553bd\",\"2、数据库_mongodb_整合.md\":\"3c47d7f4\",\"4、微服务_springsecurity_基础篇.md\":\"534a3401\",\"4、微服务_进阶.md\":\"69095c58\",\"计算机基础_计算机基础_操作系统.md\":\"0f75d113\",\"可视化 _ 监控_zabbix.md\":\"71f2270e\",\"nginx_基础篇.md\":\"c7d8bb50\",\"1、学前端_4、node_项目实战.md\":\"bc5065b8\",\"2、数据库_redis_redis原理.md\":\"5cedf685\",\"可视化 _ 监控_监控基础.md\":\"ac56ce4d\",\"三高_高并发.md\":\"ea9ffc99\",\"2、数据库_redis_redis高级.md\":\"1d5872f6\",\"1、学前端_4、node_基础篇.md\":\"581cc13a\",\"2、数据库_mongodb_基础.md\":\"fb7a0a29\",\"idea_idea基础.md\":\"6f2f9638\",\"4、微服务_必备_sentinel.md\":\"2edfbf6c\",\"2、数据库_elasticsearch_3、es高级.md\":\"ef146606\",\"1、学前端_3、vue_vue3_vue3新语法.md\":\"8afd5409\",\"消息中间件_canal.md\":\"3949163c\",\"ssm_maven.md\":\"2c5e12ed\",\"4、微服务_springsecurity_高级篇.md\":\"882d3ff3\",\"linux_linux进阶.md\":\"188ef7b4\",\"计算机基础_设计模式_uml.md\":\"634ba256\",\"计算机基础_算法_leetcode.md\":\"77162fb9\",\"项目实战_小兔鲜_进阶篇1.md\":\"17c52c81\",\"1、学前端_2、js_ts_es6 基础.md\":\"fda3f18b\",\"项目实战_小兔鲜_进阶篇2.md\":\"a0f23006\",\"软件测试_测试基础.md\":\"8c1060cd\",\"2、数据库_redis_本地缓存.md\":\"00617fe6\",\"nginx_面试篇.md\":\"e3fb373a\",\"mybatis_mybatisplus_mybatis.md\":\"9239e0ad\",\"linux_shell.md\":\"ae53d83b\",\"2、数据库_mysql_mysql核心_优化.md\":\"36230425\",\"项目实战_项目推荐.md\":\"f9d97630\",\"mybatis_mybatisplus_mybatisplus.md\":\"0030fd35\",\"项目实战_百度地图_进阶篇.md\":\"c8b93267\",\"三高_高可用.md\":\"323840c5\",\"java_java新特性.md\":\"22abf56d\",\"软件测试_压力测试.md\":\"9ab44440\",\"java学前端_html_js.md\":\"e0fcd240\",\"2、数据库_redis_redis实战.md\":\"d6daeeab\",\"nginx_进阶篇.md\":\"e6b63195\",\"三高_秒杀.md\":\"3878bb64\",\"5、运维_git.md\":\"0264925c\",\"java_java进阶.md\":\"e79cb5b4\",\"并发 _ 多线程_基础篇.md\":\"7adbfac5\",\"项目实战_百度地图_基础篇.md\":\"8afa5954\",\"java学前端_react.md\":\"3ec827dd\",\"1、学前端_1、html_css_css基础.md\":\"01b56712\",\"项目实战_小兔鲜_基础篇.md\":\"646f5df5\",\"1、学前端_2、js_ts_js 基础.md\":\"cb13e36f\",\"可视化 _ 监控_监控进阶.md\":\"0cdbc292\",\"计算机基础_设计模式_基础篇.md\":\"51617287\",\"计算机基础_数据结构_基础篇.md\":\"b2bfd8d4\",\"项目实战_苍穹外卖_进阶篇.md\":\"48415e41\",\"ssm_spring.md\":\"ab514659\",\"消息中间件_rabbitmq.md\":\"45b1eb28\",\"1、学前端_1、html_css_网页进阶.md\":\"db998248\",\"消息中间件_kafka.md\":\"b747dabf\",\"云原生_docker.md\":\"983c7ba7\",\"4、微服务_必备_分布式锁.md\":\"5af1cf8d\",\"消息中间件_rocketmq.md\":\"d441da85\",\"项目实战_黑马头条_基础篇.md\":\"b05af3a6\",\"ssm_springmvc.md\":\"81b9714f\",\"项目实战_支付.md\":\"1d7407dd\",\"项目实战_黑马头条_进阶篇2.md\":\"bff0015b\",\"项目实战_黑马头条_进阶篇.md\":\"19f18388\",\"java学前端_vue2_组件.md\":\"58c6b1df\",\"3、springboot_基础篇.md\":\"529c66f4\",\"3、springboot_应用篇.md\":\"8b92aa61\",\"项目实战_黑马头条_高级篇.md\":\"227c08c1\",\"1、学前端_5、小程序_uniapp.md\":\"71a282b4\",\"项目实战_云尚办公_基础篇.md\":\"1fe188ba\",\"并发 _ 多线程_并发完善.md\":\"26619c46\",\"1、学前端_2、js_ts_js 进阶.md\":\"657dfb8f\",\"java_java高级.md\":\"23782d1a\",\"java_java基础.md\":\"86d67c77\"}");window.__VP_SITE_DATA__=JSON.parse("{\"lang\":\"en-US\",\"dir\":\"ltr\",\"title\":\"VitePress\",\"description\":\"A VitePress site\",\"base\":\"/notebook/\",\"head\":[],\"appearance\":true,\"themeConfig\":{\"algolia\":{\"appId\":\"DW7O63I9IR\",\"apiKey\":\"f8ed758cdb288a8b06542bc35923c1a1\",\"indexName\":\"notebook\"},\"sidebar\":[{\"text\":\"Java\",\"collapsed\":true,\"items\":[{\"text\":\"Java基础\",\"link\":\"/Java/Java基础\"},{\"text\":\"Java新特性\",\"link\":\"/Java/Java新特性\"},{\"text\":\"Java进阶\",\"link\":\"/Java/Java进阶\"},{\"text\":\"Java集合\",\"link\":\"/Java/Java集合\"},{\"text\":\"Java高级\",\"link\":\"/Java/Java高级\"}]},{\"text\":\"Linux\",\"collapsed\":true,\"items\":[{\"text\":\"Linux基础\",\"link\":\"/Linux/Linux基础\"},{\"text\":\"Linux新特性\",\"link\":\"/Linux/Linux进阶\"},{\"text\":\"Shell脚本\",\"link\":\"/Linux/Shell\"},{\"text\":\"实用脚本\",\"link\":\"/Linux/实用脚本\"},{\"text\":\"软件部署\",\"link\":\"/Linux/软件部署\"}]},{\"text\":\"Nginx\",\"collapsed\":true,\"items\":[{\"text\":\"基础篇\",\"link\":\"/Nginx/基础篇\"},{\"text\":\"进阶篇\",\"link\":\"/Nginx/进阶篇\"},{\"text\":\"实战篇\",\"link\":\"/Nginx/实战篇\"},{\"text\":\"面试篇\",\"link\":\"/Nginx/面试篇\"}]},{\"text\":\"SSM\",\"collapsed\":true,\"items\":[{\"text\":\"Maven\",\"link\":\"/SSM/Maven\"},{\"text\":\"Spring\",\"link\":\"/SSM/Spring\"},{\"text\":\"SpringMVC\",\"link\":\"/SSM/SpringMVC\"},{\"text\":\"SpringBatch\",\"link\":\"/SSM/SpringBatch\"}]},{\"text\":\"SpringBoot\",\"collapsed\":true,\"items\":[{\"text\":\"基础篇\",\"link\":\"/3、SpringBoot/基础篇\"},{\"text\":\"应用篇\",\"link\":\"/3、SpringBoot/应用篇\"},{\"text\":\"新特性\",\"link\":\"/3、SpringBoot/新特性\"},{\"text\":\"运维&原理\",\"link\":\"/3、SpringBoot/运维&原理\"}]},{\"text\":\"SpringCloud\",\"collapsed\":true,\"items\":[{\"text\":\"SpringCloud\",\"link\":\"/4、微服务/进阶\"},{\"text\":\"Sentinel\",\"link\":\"/4、微服务/必备/Sentinel\"}]},{\"text\":\"SpringSecurity\",\"collapsed\":true,\"items\":[{\"text\":\"SpringSecurity基础篇\",\"link\":\"/4、微服务/SpringSecurity/基础篇\"},{\"text\":\"SpringSecurity进阶篇\",\"link\":\"/4、微服务/SpringSecurity/进阶篇\"},{\"text\":\"SpringSecurity高级篇\",\"link\":\"/4、微服务/SpringSecurity/高级篇\"}]},{\"text\":\"Mybatis & MybatisPlus\",\"collapsed\":true,\"items\":[{\"text\":\"Mybatis\",\"link\":\"/Mybatis&MybatisPlus/Mybatis\"},{\"text\":\"MybatisPlus\",\"link\":\"/Mybatis&MybatisPlus/MybatisPlus\"},{\"text\":\"JPA\",\"link\":\"/Mybatis&MybatisPlus/JPA\"}]},{\"text\":\"Git & ChatGPT\",\"collapsed\":true,\"items\":[{\"text\":\"Git\",\"link\":\"/5、运维/Git\"},{\"text\":\"Github\",\"link\":\"/5、运维/Github\"},{\"text\":\"ChatGPT\",\"link\":\"/5、运维/ChatGPT\"},{\"text\":\"Jenkins\",\"link\":\"/5、运维/Jenkins\"},{\"text\":\"Netty\",\"link\":\"/5、运维/Netty\"}]},{\"text\":\"数据库\",\"collapsed\":true,\"items\":[{\"text\":\"MySQL\",\"collapsed\":true,\"items\":[{\"text\":\"MySQL基础\",\"link\":\"/2、数据库/MySQL/MySQL核心/基础\"},{\"text\":\"MySQL进阶\",\"link\":\"/2、数据库/MySQL/MySQL核心/进阶\"},{\"text\":\"MySQL优化\",\"link\":\"/2、数据库/MySQL/MySQL核心/优化\"},{\"text\":\"MySQL设计\",\"link\":\"/2、数据库/MySQL/MySQL核心/设计\"},{\"text\":\"MySQL运维\",\"link\":\"/2、数据库/MySQL/MySQL核心/运维\"},{\"text\":\"分库分表\",\"link\":\"/2、数据库/MySQL/分库分表\"}]},{\"text\":\"Redis\",\"collapsed\":true,\"items\":[{\"text\":\"Redis基础\",\"link\":\"/2、数据库/Redis/Redis基础\"},{\"text\":\"Redis优化\",\"link\":\"/2、数据库/Redis/Redis优化\"},{\"text\":\"Redis原理\",\"link\":\"/2、数据库/Redis/Redis原理\"},{\"text\":\"Redis高级\",\"link\":\"/2、数据库/Redis/Redis高级\"},{\"text\":\"Redis实战\",\"link\":\"/2、数据库/Redis/Redis实战\"},{\"text\":\"本地缓存\",\"link\":\"/2、数据库/Redis/本地缓存\"}]},{\"text\":\"MongoDB\",\"collapsed\":true,\"items\":[{\"text\":\"MongoDB基础\",\"link\":\"/2、数据库/MongoDB/基础\"},{\"text\":\"MongoDB进阶\",\"link\":\"/2、数据库/MongoDB/整合\"}]},{\"text\":\"ElasticSearch\",\"collapsed\":true,\"items\":[{\"text\":\"ES基础\",\"link\":\"/2、数据库/ElasticSearch/1、ES基础\"},{\"text\":\"ES高级\",\"link\":\"/2、数据库/ElasticSearch/3、ES高级\"}]},{\"text\":\"InfluxDB\",\"link\":\"/2、数据库/influxdb\"},{\"text\":\"Neo4j\",\"link\":\"/2、数据库/Neo4j\"}]},{\"text\":\"高并发 & 秒杀 & 分布式\",\"collapsed\":true,\"items\":[{\"text\":\"分布式理论\",\"link\":\"/三高/分布式\"},{\"text\":\"分布式锁\",\"link\":\"/4、微服务/必备/分布式锁\"},{\"text\":\"秒杀\",\"link\":\"/三高/秒杀\"},{\"text\":\"高可用\",\"link\":\"/三高/高可用\"},{\"text\":\"高并发\",\"link\":\"/三高/高并发\"}]},{\"text\":\"云原生\",\"collapsed\":true,\"items\":[{\"text\":\"Docker\",\"link\":\"/云原生/Docker\"},{\"text\":\"K8S\",\"link\":\"/云原生/K8S\"}]},{\"text\":\"可视化 & 监控\",\"collapsed\":true,\"items\":[{\"text\":\"监控基础\",\"link\":\"/可视化 & 监控/监控基础\"},{\"text\":\"监控进阶\",\"link\":\"/可视化 & 监控/监控进阶\"},{\"text\":\"可视化大屏\",\"link\":\"/可视化 & 监控/可视化大屏\"},{\"text\":\"Zabbix\",\"link\":\"/可视化 & 监控/Zabbix\"}]},{\"text\":\"学前端\",\"collapsed\":true,\"items\":[{\"text\":\"HTML+CSS\",\"collapsed\":true,\"items\":[{\"text\":\"HTML基础\",\"link\":\"/1、学前端/1、HTML+CSS/HTML基础\"},{\"text\":\"CSS基础\",\"link\":\"/1、学前端/1、HTML+CSS/CSS基础\"},{\"text\":\"网页进阶\",\"link\":\"/1、学前端/1、HTML+CSS/网页进阶\"}]},{\"text\":\"JS+TS\",\"collapsed\":true,\"items\":[{\"text\":\"JS基础\",\"link\":\"/1、学前端/2、JS+TS/JS 基础\"},{\"text\":\"JS进阶\",\"link\":\"/1、学前端/2、JS+TS/JS 进阶\"},{\"text\":\"ES6基础\",\"link\":\"/1、学前端/2、JS+TS/ES6 基础\"},{\"text\":\"ES6进阶\",\"link\":\"/1、学前端/2、JS+TS/ES6 进阶\"},{\"text\":\"TS基础\",\"link\":\"/1、学前端/2、JS+TS/TypeScript\"}]},{\"text\":\"NodeJS\",\"collapsed\":true,\"items\":[{\"text\":\"Node基础\",\"link\":\"/1、学前端/4、Node/基础篇\"},{\"text\":\"Node进阶\",\"link\":\"/1、学前端/4、Node/进阶篇\"},{\"text\":\"项目实战\",\"link\":\"/1、学前端/4、Node/项目实战\"}]},{\"text\":\"Vue\",\"collapsed\":true,\"items\":[{\"text\":\"Vue3进阶\",\"link\":\"/1、学前端/3、Vue/Vue3/Vue3进阶\"},{\"text\":\"Vue3高级\",\"link\":\"/1、学前端/3、Vue/Vue3/Vue3高级\"},{\"text\":\"Vue3新语法\",\"link\":\"/1、学前端/3、Vue/Vue3/Vue3新语法\"},{\"text\":\"项目实战\",\"link\":\"/1、学前端/3、Vue/Vue2/Vue2项目\"}]},{\"text\":\"小程序\",\"collapsed\":true,\"items\":[{\"text\":\"小程序基础\",\"link\":\"/1、学前端/5、小程序/微信小程序\"},{\"text\":\"小程序优化\",\"link\":\"/1、学前端/5、小程序/小程序优化\"},{\"text\":\"uniapp\",\"link\":\"/1、学前端/5、小程序/uniapp\"},{\"text\":\"项目实战\",\"link\":\"/1、学前端/5、小程序/小程序项目\"}]}]},{\"text\":\"计算机基础\",\"collapsed\":true,\"items\":[{\"text\":\"数据结构\",\"link\":\"/计算机基础/数据结构/基础篇\"},{\"text\":\"操作系统\",\"link\":\"/计算机基础/计算机基础/操作系统\"},{\"text\":\"设计模式\",\"link\":\"/计算机基础/设计模式/基础篇\"},{\"text\":\"计算机网络\",\"link\":\"/计算机基础/计算机网络/网络基础\"},{\"text\":\"UML\",\"link\":\"/计算机基础/设计模式/UML\"},{\"text\":\"LeetCode\",\"link\":\"/计算机基础/算法/LeetCode\"}]},{\"text\":\"项目实战\",\"collapsed\":true,\"items\":[{\"text\":\"云尚办公\",\"collapsed\":true,\"items\":[{\"text\":\"基础篇\",\"link\":\"/项目实战/云尚办公/基础篇\"}]},{\"text\":\"小兔鲜\",\"collapsed\":true,\"items\":[{\"text\":\"基础篇\",\"link\":\"/项目实战/小兔鲜/基础篇\"},{\"text\":\"进阶篇1\",\"link\":\"/项目实战/小兔鲜/进阶篇1\"},{\"text\":\"进阶篇2\",\"link\":\"/项目实战/小兔鲜/进阶篇2\"}]},{\"text\":\"地图\",\"collapsed\":true,\"items\":[{\"text\":\"基础篇\",\"link\":\"/项目实战/百度地图/基础篇\"},{\"text\":\"进阶篇\",\"link\":\"/项目实战/百度地图/进阶篇\"}]},{\"text\":\"苍穹外卖\",\"collapsed\":true,\"items\":[{\"text\":\"进阶篇\",\"link\":\"/项目实战/苍穹外卖/进阶篇\"}]},{\"text\":\"黑马头条\",\"collapsed\":true,\"items\":[{\"text\":\"基础篇\",\"link\":\"/项目实战/黑马头条/基础篇\"},{\"text\":\"进阶篇\",\"link\":\"/项目实战/黑马头条/进阶篇\"},{\"text\":\"进阶篇2\",\"link\":\"/项目实战/黑马头条/进阶篇2\"},{\"text\":\"高级篇\",\"link\":\"/项目实战/黑马头条/高级篇\"}]},{\"text\":\"支付\",\"link\":\"/项目实战/支付\"},{\"text\":\"项目推荐\",\"link\":\"/项目实战/项目推荐\"}]},{\"text\":\"团队成员\",\"link\":\"/team\"}],\"siteTitle\":\"任硕的文档\",\"logo\":\"/Vue.png\",\"nav\":[{\"text\":\"Java学前端\",\"items\":[{\"items\":[{\"text\":\"HTML+JS\",\"link\":\"/Java学前端/HTML+JS\"},{\"text\":\"CSS\",\"link\":\"/Java学前端/CSS\"},{\"text\":\"Vue2+组件\",\"link\":\"/Java学前端/Vue2+组件\"},{\"text\":\"Vue3+组件\",\"link\":\"/Java学前端/Vue3+组件\"},{\"text\":\"React\",\"link\":\"/Java学前端/React\"}]}],\"activeMatch\":\"/Java/\"},{\"text\":\"软件测试\",\"items\":[{\"items\":[{\"text\":\"测试基础\",\"link\":\"/软件测试/测试基础\"},{\"text\":\"压力测试\",\"link\":\"/软件测试/压力测试\"}]}]},{\"text\":\"多线程\",\"items\":[{\"items\":[{\"text\":\"基础篇\",\"link\":\"/并发 & 多线程/基础篇\"},{\"text\":\"进阶篇\",\"link\":\"/并发 & 多线程/并发完善\"}]}]},{\"text\":\"开发工具\",\"items\":[{\"items\":[{\"text\":\"Chrome\",\"link\":\"/IDEA/Chrome\"},{\"text\":\"IDEA基础\",\"link\":\"/IDEA/IDEA基础\"},{\"text\":\"IDEA插件\",\"link\":\"/IDEA/IDEA插件\"},{\"text\":\"VS Code\",\"link\":\"/IDEA/VS Code\"}]}]},{\"text\":\"消息中间件\",\"items\":[{\"items\":[{\"text\":\"RabbitMQ\",\"link\":\"/消息中间件/RabbitMQ\"},{\"text\":\"RocketMQ\",\"link\":\"/消息中间件/RocketMQ\"},{\"text\":\"Kafka\",\"link\":\"/消息中间件/Kafka\"},{\"text\":\"Canal\",\"link\":\"/消息中间件/Canal\"}]}]}],\"socialLinks\":[{\"icon\":\"github\",\"link\":\"https://github.com/renshuo123/renshuo123.github.io\"},{\"icon\":\"twitter\",\"link\":\"#\"},{\"icon\":{\"svg\":\"<svg t=\\\"1676028692954\\\" class=\\\"icon\\\" ...</path></svg>\"},\"link\":\"https://github.com/\"}]},\"locales\":{},\"scrollOffset\":90,\"cleanUrls\":false}");</script>
    
  </body>
</html>